コード例 #1
0
        public AssettoCorsaConnector()
            : base(AcExecutables)
        {
            _dependencies = new DependencyChecker(
                new IDependency[]
            {
                new DirectoryExistsDependency(@"apps\python\SecondMonitor"),
                new DirectoryExistsDependency(@"apps\python\SecondMonitor\stdlib"),
                new DirectoryExistsDependency(@"apps\python\SecondMonitor\stdlib64"),
                new FileExistsAndMatchDependency(
                    @"apps\python\SecondMonitor\SecondMonitor.py",
                    @"Connectors\AssettoCorsa\SecondMonitor.py"),
                new FileExistsAndMatchDependency(
                    @"apps\python\SecondMonitor\smshared_mem.py",
                    @"Connectors\AssettoCorsa\smshared_mem.py"),
                new FileExistsAndMatchDependency(
                    @"apps\python\SecondMonitor\stdlib\_ctypes.pyd",
                    @"Connectors\AssettoCorsa\stdlib\_ctypes.pyd"),
                new FileExistsAndMatchDependency(
                    @"apps\python\SecondMonitor\stdlib64\_ctypes.pyd",
                    @"Connectors\AssettoCorsa\stdlib64\_ctypes.pyd"),
            },
                () => true);

            _assettoCorsaStartObserver = new AssettoCorsaStartObserver();
            _physicsBuffer             = new MappedBuffer <SPageFilePhysics>(AssettoCorsaShared.SharedMemoryNamePhysics);
            _graphicsBuffer            = new MappedBuffer <SPageFileGraphic>(AssettoCorsaShared.SharedMemoryNameGraphic);
            _staticBuffer        = new MappedBuffer <SPageFileStatic>(AssettoCorsaShared.SharedMemoryNameStatic);
            _secondMonitorBuffer = new MappedBuffer <SPageFileSecondMonitor>(AssettoCorsaShared.SharedMemoryNameSecondMonitor);
            _acDataConverter     = new AcDataConverter(this, _assettoCorsaStartObserver);
            _rawLastSessionType  = AcSessionType.AC_UNKNOWN;
            _lastSessionType     = SessionType.Na;
            _lastSessionPhase    = SessionPhase.Countdown;
            _stopwatch           = new Stopwatch();
        }
コード例 #2
0
 protected override void ResetConnector()
 {
     _stopwatch.Restart();
     _rawLastSessionType = AcSessionType.AC_UNKNOWN;
     _lastSessionType    = SessionType.Na;
     _lastSessionPhase   = SessionPhase.Countdown;
     _lastDataSet        = null;
 }
コード例 #3
0
        private bool CheckSessionStarted(AssettoCorsaShared acData, SimulatorDataSet dataSet)
        {
            if (_rawLastSessionType != acData.AcsGraphic.session || _lastSessionType != dataSet.SessionInfo.SessionType)
            {
                _lastSessionType    = dataSet.SessionInfo.SessionType;
                _rawLastSessionType = acData.AcsGraphic.session;
                _lastSessionPhase   = dataSet.SessionInfo.SessionPhase;
                Logger.Info("Session restart cause - Session Type Change");
                return(true);
            }

            if (dataSet.SessionInfo.SessionPhase != _lastSessionPhase && _lastSessionPhase != SessionPhase.Green &&
                dataSet.SessionInfo.SessionPhase
                != SessionPhase.Countdown)
            {
                _lastSessionType    = dataSet.SessionInfo.SessionType;
                _rawLastSessionType = acData.AcsGraphic.session;
                _lastSessionPhase   = dataSet.SessionInfo.SessionPhase;
                Logger.Info("Session restart cause - Session Phase Change");
                _assettoCorsaStartObserver.ResetStartState();
                return(true);
            }

            if (_lastDataSet == null)
            {
                return(false);
            }

            if (_lastDataSet.PlayerInfo?.CompletedLaps > dataSet.PlayerInfo?.CompletedLaps)
            {
                Logger.Info("Session restart cause - Less Completed Laps than previously");
                _assettoCorsaStartObserver.ResetStartState();
                return(true);
            }

            if (_lastDataSet.SessionInfo.SessionType == SessionType.Race && _lastDataSet.SessionInfo.LeaderCurrentLap
                > dataSet.SessionInfo.LeaderCurrentLap)
            {
                Logger.Info("Session restart cause - Less Leader Completed Laps than previously");
                _assettoCorsaStartObserver.ResetStartState();
                return(true);
            }


            return(false);
        }
コード例 #4
0
        private bool CheckSessionStarted(AssettoCorsaShared acData, SimulatorDataSet dataSet)
        {
            if (_rawLastSessionType != acData.AcsGraphic.session || _lastSessionType != dataSet.SessionInfo.SessionType)
            {
                _lastSessionType    = dataSet.SessionInfo.SessionType;
                _rawLastSessionType = acData.AcsGraphic.session;
                _lastSessionPhase   = dataSet.SessionInfo.SessionPhase;
                return(true);
            }

            if (dataSet.SessionInfo.SessionPhase != _lastSessionPhase && _lastSessionPhase != SessionPhase.Green &&
                dataSet.SessionInfo.SessionPhase
                != SessionPhase.Countdown)
            {
                _lastSessionType    = dataSet.SessionInfo.SessionType;
                _rawLastSessionType = acData.AcsGraphic.session;
                _lastSessionPhase   = dataSet.SessionInfo.SessionPhase;
                return(true);
            }

            if (_lastDataSet == null)
            {
                return(false);
            }

            if (_lastDataSet.PlayerInfo?.CompletedLaps > dataSet.PlayerInfo?.CompletedLaps)
            {
                return(true);
            }

            if (_lastDataSet.SessionInfo.SessionType == SessionType.Race && _lastDataSet.SessionInfo.LeaderCurrentLap
                > dataSet.SessionInfo.LeaderCurrentLap)
            {
                return(true);
            }


            return(false);
        }