instance

package
v1.25.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 29, 2024 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WinCpuPriorityRealtime    = 256
	WinCpuPriorityHigh        = 128
	WinCpuPriorityAboveNormal = 32768
	WinCpuPriorityNormal      = 32
	WinCpuPriorityBelowNormal = 16384
	WinCpuPriorityLow         = 64
)

Variables

View Source
var (
	ErrServerCantBeRunning = errors.New("server instance cant be running to perform this action")
	ErrServerDirIsInvalid  = errors.New("server directory is invalid")
	ErrInvalidCoreAffinity = errors.New("invalid core affinity value")
	ErrInvalidCpuPriority  = errors.New("invalid cpu priority value")
)
View Source
var DefaultCoreAffinity = uint(math.Pow(2, float64(runtime.NumCPU()))) - 1

Functions

func SetConfigVersion

func SetConfigVersion(settings *AccConfigFiles)

Types

type AccConfigFiles

type AccConfigFiles struct {
	Configuration ConfigurationJson `json:"configuration"`
	Settings      SettingsJson      `json:"settings"`
	Event         EventJson         `json:"event"`
	EventRules    EventRulesJson    `json:"eventRules"`
	Entrylist     EntrylistJson     `json:"entrylist"`
	Bop           BopJson           `json:"bop"`
	AssistRules   AssistRulesJson   `json:"assistRules"`
}

type AccWebAdvWindowsSettingsJson added in v1.20.0

type AccWebAdvWindowsSettingsJson struct {
	CpuPriority  uint `json:"cpuPriority"`
	CoreAffinity uint `json:"coreAffinity"`
	EnableWinFW  bool `json:"enableWindowsFirewall"`
}

type AccWebConfigJson

type AccWebConfigJson struct {
	ID        string             `json:"id"`
	Md5Sum    string             `json:"md5Sum"`
	AutoStart bool               `json:"autoStart"` // backward compatibility
	Settings  AccWebSettingsJson `json:"settings"`
	CreatedAt time.Time          `json:"createdAt"`
	UpdatedAt time.Time          `json:"updatedAt"`
}

func (*AccWebConfigJson) SetUpdateAt

func (a *AccWebConfigJson) SetUpdateAt()

type AccWebSettingsJson added in v1.20.0

type AccWebSettingsJson struct {
	AutoStart       bool                          `json:"autoStart"`
	EnableAdvWinCfg bool                          `json:"enableAdvWindowsCfg"`
	AdvWindowsCfg   *AccWebAdvWindowsSettingsJson `json:"advWindowsCfg"`
}

type AssistRulesJson

type AssistRulesJson struct {
	ConfigVersion            int `json:"configVersion"`
	StabilityControlLevelMax int `json:"stabilityControlLevelMax"`
	DisableAutosteer         int `json:"disableAutosteer"`
	DisableAutoLights        int `json:"disableAutoLights"`
	DisableAutoWiper         int `json:"disableAutoWiper"`
	DisableAutoEngineStart   int `json:"disableAutoEngineStart"`
	DisableAutoPitLimiter    int `json:"disableAutoPitLimiter"`
	DisableAutoGear          int `json:"disableAutoGear"`
	DisableAutoClutch        int `json:"disableAutoClutch"`
	DisableIdealLine         int `json:"disableIdealLine"`
}

type BopJson

type BopJson struct {
	ConfigVersion int           `json:"configVersion"`
	Entries       []BopSettings `json:"entries"`
}

type BopSettings

type BopSettings struct {
	Track      string `json:"track"`
	CarModel   int    `json:"carModel"`
	BallastKg  int    `json:"ballastKg"`
	Restrictor int    `json:"restrictor"`
}

type CarState added in v1.16.0

type CarState struct {
	CarID              int            `json:"carID"`
	RaceNumber         int            `json:"raceNumber"`
	CarModel           int            `json:"carModel"`
	Drivers            []*DriverState `json:"drivers"`
	CurrentDriver      *DriverState   `json:"currentDriver"`
	Fuel               int            `json:"fuel"`
	Position           int            `json:"position"`
	NrLaps             int            `json:"nrLaps"`
	BestLapMS          int            `json:"bestLapMS"`
	LastLapMS          int            `json:"lastLapMS"`
	LastLapTimestampMS int            `json:"lastLapTimestampMS"`
	Laps               []*LapState    `json:"laps"`
	CurrLap            LapState       `json:"currLap"`
}

CarState represents the current state of a single car

type ConfigurationJson

type ConfigurationJson struct {
	ConfigVersion   int    `json:"configVersion"`
	UdpPort         int    `json:"udpPort"`
	TcpPort         int    `json:"tcpPort"`
	MaxConnections  int    `json:"maxConnections"`
	RegisterToLobby int    `json:"registerToLobby"`
	LanDiscovery    int    `json:"lanDiscovery"`
	PublicIP        string `json:"publicIP"`
}

type DriverSettings

type DriverSettings struct {
	FirstName      string `json:"firstName"`
	LastName       string `json:"lastName"`
	ShortName      string `json:"shortName"`
	DriverCategory int    `json:"driverCategory"`
	PlayerID       string `json:"playerID"`
	Nationality    int    `json:"nationality"`
}

type DriverState added in v1.16.0

type DriverState struct {
	ConnectionID int    `json:"-"`
	Name         string `json:"name"`
	PlayerID     string `json:"playerID"`
	// contains filtered or unexported fields
}

DriverState contains the information about a single driver

type EntrySettings

type EntrySettings struct {
	Drivers                      []DriverSettings `json:"drivers"`
	RaceNumber                   int              `json:"raceNumber"`
	ForcedCarModel               int              `json:"forcedCarModel"`
	OverrideDriverInfo           int              `json:"overrideDriverInfo"`
	IsServerAdmin                int              `json:"isServerAdmin"`
	CustomCar                    string           `json:"customCar"`
	OverrideCarModelForCustomCar int              `json:"overrideCarModelForCustomCar"`
	BallastKg                    int              `json:"ballastKg"`
	Restrictor                   int              `json:"restrictor"`
	DefaultGridPosition          int              `json:"defaultGridPosition"`
}

type EntrylistJson

type EntrylistJson struct {
	ConfigVersion  int             `json:"configVersion"`
	Entries        []EntrySettings `json:"entries"`
	ForceEntryList int             `json:"forceEntryList"`
}

type EventJson

type EventJson struct {
	ConfigVersion                 int               `json:"configVersion"`
	Track                         string            `json:"track"`
	PreRaceWaitingTimeSeconds     int               `json:"preRaceWaitingTimeSeconds"`
	SessionOverTimeSeconds        int               `json:"sessionOverTimeSeconds"`
	AmbientTemp                   int               `json:"ambientTemp"`
	TrackTemp                     int               `json:"trackTemp,omitempty"`
	CloudLevel                    float64           `json:"cloudLevel"`
	Rain                          float64           `json:"rain"`
	WeatherRandomness             int               `json:"weatherRandomness"`
	Sessions                      []SessionSettings `json:"sessions"`
	MetaData                      string            `json:"metaData"`
	PostQualySeconds              int               `json:"postQualySeconds"`
	PostRaceSeconds               int               `json:"postRaceSeconds"`
	SimracerWeatherConditions     int               `json:"simracerWeatherConditions"`
	IsFixedConditionQualification int               `json:"isFixedConditionQualification"`
}

type EventRulesJson

type EventRulesJson struct {
	ConfigVersion                        int  `json:"configVersion"`
	QualifyStandingType                  int  `json:"qualifyStandingType"`
	PitWindowLengthSec                   int  `json:"pitWindowLengthSec"`
	DriverStintTimeSec                   int  `json:"driverStintTimeSec"`
	MandatoryPitstopCount                int  `json:"mandatoryPitstopCount"`
	MaxTotalDrivingTime                  int  `json:"maxTotalDrivingTime"`
	MaxDriversCount                      int  `json:"maxDriversCount"`
	IsRefuellingAllowedInRace            bool `json:"isRefuellingAllowedInRace"`
	IsRefuellingTimeFixed                bool `json:"isRefuellingTimeFixed"`
	IsMandatoryPitstopRefuellingRequired bool `json:"isMandatoryPitstopRefuellingRequired"`
	IsMandatoryPitstopTyreChangeRequired bool `json:"isMandatoryPitstopTyreChangeRequired"`
	IsMandatoryPitstopSwapDriverRequired bool `json:"isMandatoryPitstopSwapDriverRequired"`
	TyreSetCount                         int  `json:"tyreSetCount"`
}

type Instance

type Instance struct {
	Path   string
	Cfg    AccWebConfigJson
	AccCfg AccConfigFiles
	Live   *LiveState
	// contains filtered or unexported fields
}

func LoadServerFromPath

func LoadServerFromPath(baseDir string) (*Instance, error)

LoadServerFromPath load the server configuration data based on baseDir and returns a Instance instance

func (*Instance) CanSaveSettings added in v1.20.0

func (s *Instance) CanSaveSettings(aw AccWebSettingsJson, ac AccConfigFiles) error

func (*Instance) CheckDirectory

func (s *Instance) CheckDirectory() error

func (*Instance) CheckServerExeMd5Sum

func (s *Instance) CheckServerExeMd5Sum() (bool, error)

func (*Instance) ExportConfigFilesToZip

func (s *Instance) ExportConfigFilesToZip() ([]byte, error)

func (*Instance) GetAccServerLogs

func (s *Instance) GetAccServerLogs() ([]byte, error)

func (*Instance) GetID

func (s *Instance) GetID() string

func (*Instance) GetProcessID

func (s *Instance) GetProcessID() int

func (*Instance) HasAdvancedWindowsConfig added in v1.20.0

func (s *Instance) HasAdvancedWindowsConfig() bool

func (*Instance) IsRunning

func (s *Instance) IsRunning() bool

func (*Instance) Save

func (s *Instance) Save() error

func (*Instance) Start

func (s *Instance) Start() error

func (*Instance) Stop

func (s *Instance) Stop() error

func (*Instance) UpdateAccServerExe

func (s *Instance) UpdateAccServerExe(srcFile string) (bool, error)

type LapState added in v1.16.0

type LapState struct {
	CarID       int          `json:"carID"`
	DriverIndex int          `json:"driverIndex"`
	Car         *CarState    `json:"-"`
	Driver      *DriverState `json:"-"`
	LapTimeMS   int          `json:"lapTimeMS"`
	TimestampMS int          `json:"timestampMS"`
	Flags       int          `json:"flags"`
	S1          string       `json:"s1"`
	S2          string       `json:"s2"`
	S3          string       `json:"s3"`
	Fuel        int          `json:"fuel"`
	HasCut      bool         `json:"hasCut"`
	InLap       bool         `json:"inLap"`
	OutLap      bool         `json:"outLap"`
	SessionOver bool         `json:"sessionOver"`
}

type LiveState added in v1.16.0

type LiveState struct {
	ServerState      ServerState       `json:"serverState"`
	NrClients        int               `json:"nrClients"`
	Track            string            `json:"track"`
	SessionType      string            `json:"sessionType"`
	SessionPhase     string            `json:"sessionPhase"`
	SessionRemaining int               `json:"sessionRemaining"`
	Cars             map[int]*CarState `json:"cars"`
	UpdatedAt        time.Time         `json:"updatedAt"`
	Chats            []ServerChat      `json:"chats"`
	// contains filtered or unexported fields
}

func NewLiveState added in v1.16.1

func NewLiveState() *LiveState

type ServerChat added in v1.18.0

type ServerChat struct {
	Timestamp time.Time `json:"ts"`
	Name      string    `json:"name"`
	Message   string    `json:"message"`
}

type ServerState added in v1.16.0

type ServerState string
const (
	ServerStateOffline       ServerState = "offline"
	ServerStateStarting      ServerState = "starting"
	ServerStateStoping       ServerState = "stoping"
	ServerStateNotRegistered ServerState = "not_registered"
	ServerStateOnline        ServerState = "online"
)

type SessionSettings

type SessionSettings struct {
	HourOfDay              int    `json:"hourOfDay"`
	DayOfWeekend           int    `json:"dayOfWeekend"`
	TimeMultiplier         int    `json:"timeMultiplier"`
	SessionType            string `json:"sessionType"`
	SessionDurationMinutes int    `json:"sessionDurationMinutes"`
}

type SettingsJson

type SettingsJson struct {
	ConfigVersion              int    `json:"configVersion"`
	ServerName                 string `json:"serverName"`
	Password                   string `json:"password"`
	AdminPassword              string `json:"adminPassword"`
	SpectatorPassword          string `json:"spectatorPassword"`
	TrackMedalsRequirement     int    `json:"trackMedalsRequirement"`
	SafetyRatingRequirement    int    `json:"safetyRatingRequirement"`
	RacecraftRatingRequirement int    `json:"racecraftRatingRequirement"`
	IgnorePrematureDisconnects int    `json:"ignorePrematureDisconnects"`
	DumpLeaderboards           int    `json:"dumpLeaderboards"`
	IsRaceLocked               int    `json:"isRaceLocked"`
	RandomizeTrackWhenEmpty    int    `json:"randomizeTrackWhenEmpty"`
	MaxCarSlots                int    `json:"maxCarSlots"`
	CentralEntryListPath       string `json:"centralEntryListPath"`
	ShortFormationLap          int    `json:"shortFormationLap"`
	AllowAutoDQ                int    `json:"allowAutoDQ"`
	DumpEntryList              int    `json:"dumpEntryList"`
	FormationLapType           int    `json:"formationLapType"`
	CarGroup                   string `json:"carGroup"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL