public void Stop(HomeSimCockpitSDK.StartStopType StartStopType) { foreach (PanelConfiguration panel in _panels) { panel.Close(); } }
public void Stop(HomeSimCockpitSDK.StartStopType StartStopType) { // zatrzymanie watka _working = false; if (_events != null && _events.Count > 0) { lock (_events) { for (int i = 0; i < _events.Count; i++) { _events[i].Set(); } } _events.Clear(); } if (_processingThreads != null && _processingThreads.Length > 0) { Thread.Sleep(100); for (int i = 0; i < _processingThreads.Length; i++) { try { _processingThreads[i].Abort(); } catch { } } _processingThreads = null; } }
public void Start(HomeSimCockpitSDK.StartStopType StartStartStopType) { _working = true; // wystartowanie wątka, który połączy się z serwerem _thread = new Thread(new ThreadStart(ServerThread)); _thread.Start(); }
public void Start(HomeSimCockpitSDK.StartStopType StartStartStopType) { Stop(HomeSimCockpitSDK.StartStopType.Input); _working = true; // wystartowanie watka (jesli sa jakies zmienne do sledzenia) List <InputVariable> vs = new List <InputVariable>(); if (_inputs != null) { for (int i = 0; i < _inputs.Length; i++) { if (_inputs[i].IsSubscribed) { _inputs[i].Module = this; _inputs[i].Reset(); vs.Add(_inputs[i]); } } } _spiesVariables = vs.ToArray(); if (_spiesVariables.Length > 0) { // wystartowanie wątka _processingThread = new Thread(new ThreadStart(ProcessingMethod)); _processingThread.Start(); } }
public void Stop(HomeSimCockpitSDK.StartStopType stopType) { _working = false; _event.Set(); Thread.Sleep(10); if (_thread != null) { try { _thread.Abort(); } catch { } _thread = null; } IDevice d = new Device(_configuration.LPTAddress); if (_configuration.LCD1.Enabled) { _configuration.LCD1.Device = d; _configuration.LCD1.Uninitialize(); } if (_configuration.LCD2.Enabled) { _configuration.LCD2.Device = d; _configuration.LCD2.Uninitialize(); } }
public void Start(HomeSimCockpitSDK.StartStopType startStopType) { _working = true; for (int i = 0; i < _outputs.Length; i++) { _outputs[i].Reset(); _outputs[i].Mouse = this; } }
public void Stop(HomeSimCockpitSDK.StartStopType startStopType) { // zamknięcie uchwytów foreach (KeyValuePair <int, PPJoy.VirtualJoystick> kvp in _joysticks) { try { kvp.Value.Dispose(); } catch {} } _joysticks.Clear(); }
public void Stop(HomeSimCockpitSDK.StartStopType startStopType) { if (!_working) { return; } foreach (simINDevices simin in _devices) { simin.Stop(true); } _devices.Clear(); _working = false; }
public void Stop(HomeSimCockpitSDK.StartStopType StartStopType) { // zatrzymanie watka _working = false; if (_processingThread != null) { try { _processingThread.Abort(); } catch { } _processingThread = null; } }
public void Start(HomeSimCockpitSDK.StartStopType StartStartStopType) { if (_variablesListeners.Count == 0) { return; } foreach (KeyValuePair <string, VariableEvent> kvp in _variablesListeners) { kvp.Value.Value = 0; } _working = true; // wystartowanie wątka, który połączy się z serwerem _thread = new Thread(new ThreadStart(ListeningThread)); _thread.Start(); }
public void Stop(HomeSimCockpitSDK.StartStopType startStopType) { // zatrzymanie wszystkich urządzeń for (int i = 0; i < _configuration.COMNAVs.Length; i++) { _configuration.COMNAVs[i].Disable(); } for (int i = 0; i < _configuration.FCUs.Length; i++) { _configuration.FCUs[i].Disable(); } for (int i = 0; i < _configuration.EFISs.Length; i++) { _configuration.EFISs[i].Disable(); } }
public void Stop(HomeSimCockpitSDK.StartStopType stopType) { _working = false; // zatrzymanie wszystkich wątków if (_readingThreads != null) { Thread.Sleep(500); for (int i = 0; i < _readingThreads.Length; i++) { try { _readingThreads[i].Join(100); } catch {} if (_readingThreads[i].IsAlive) { try { _readingThreads[i].Abort(); } catch {} _readingThreads[i] = null; } } _readingThreads = null; } // zamknięcie wszystkich urządzeń foreach (Device d in _usedDevice) { d.Close(); } _usedDevice.Clear(); // przywrócenie konfiguracji enkoderów foreach (EncoderInput ei in _encoders) { ei.Clear(); } _encoders.Clear(); }
public void Start(HomeSimCockpitSDK.StartStopType startStopType) { for (int i = 0; i < _configuration.FCUs.Length; i++) { _configuration.FCUs[i].Log = _log; _configuration.FCUs[i].Module = this; } for (int i = 0; i < _configuration.COMNAVs.Length; i++) { _configuration.COMNAVs[i].Log = _log; _configuration.COMNAVs[i].Module = this; } for (int i = 0; i < _configuration.EFISs.Length; i++) { _configuration.EFISs[i].Log = _log; _configuration.EFISs[i].Module = this; } }
public void Start(HomeSimCockpitSDK.StartStopType startType) { _working = true; _queue.Clear(); if (_registered.Count > 0) { _port = new LPTPort(_configuration.LPTAddress); _configuration.LCD1.Device = this; if (_configuration.LCD1.Enabled) { _configuration.LCD1.Initialize(); } _configuration.LCD2.Device = this; if (_configuration.LCD2.Enabled) { _configuration.LCD2.Initialize(); } _thread = new Thread(new ThreadStart(ProcessingThread)); _thread.Start(); } }
public void Start(HomeSimCockpitSDK.StartStopType StartStartStopType) { Stop(HomeSimCockpitSDK.StartStopType.Output); _writeQueue.Clear(); _working = true; _signal.Reset(); _flush.Reset(); _autoFlush.SetValue(true, null); // wystartowanie watka (jesli sa jakies zmienne zarejestrowane do zmian) if (_registered.Count > 0) { foreach (KeyValuePair <string, OutputVariable> kvp in _registered) { kvp.Value.Module = this; } // wystartowanie wątka _processingThread = new Thread(new ThreadStart(ProcessingMethod)); _processingThread.Start(); } }
public void Start(HomeSimCockpitSDK.StartStopType startStopType) { StopTimers(); // sprawdzenie czy są jakieś timery List <Timer> timers = new List <Timer>(); for (int i = 0; i < _timers.Length; i++) { _timers[i].Reset(); if (_timers[i].IsSubscribed) { timers.Add(_timers[i]); } } _subscribedTimers = timers.ToArray(); if (_subscribedTimers.Length > 0) { StartTimers(); } }
public void Start(HomeSimCockpitSDK.StartStopType StartStartStopType) { Stop(HomeSimCockpitSDK.StartStopType.Input); _working = true; if (_inputs != null && _inputs.Length > 0) { Dictionary <Controller, List <InputVariable> > cv = new Dictionary <Controller, List <InputVariable> >(); for (int i = 0; i < _inputs.Length; i++) { if (_inputs[i].IsSubscribed) { _inputs[i].Module = this; if (!cv.ContainsKey(_inputs[i].Controller)) { cv.Add(_inputs[i].Controller, new List <InputVariable>()); } cv[_inputs[i].Controller].Add(_inputs[i]); } } if (cv.Count > 0) { _processingThreads = new Thread[cv.Count]; _events = new List <AutoResetEvent>(); int index = 0; foreach (KeyValuePair <Controller, List <InputVariable> > kvp in cv) { _processingThreads[index] = new Thread(new ParameterizedThreadStart(ProcessingMethod)); _processingThreads[index].Start(new object[] { kvp.Key, kvp.Value.ToArray() }); index++; } } } }
public void Stop(HomeSimCockpitSDK.StartStopType StartStopType) { _working = false; _event.Set(); // zatrzymanie wątka połączonego z serwerem if (_thread != null) { try { if (_thread.IsAlive) { _thread.Join(500); } if (_thread.IsAlive) { _thread.Abort(); } } catch { } _thread = null; } }
public void Stop(HomeSimCockpitSDK.StartStopType startStopType) { _working = false; if (_stream != null) { try { _stream.Close(); _stream.Dispose(); } catch { } finally { _stream = null; } } // zatrzymanie wątka połączonego z serwerem if (_thread != null) { try { if (_thread.IsAlive) { _thread.Join(100); } if (_thread.IsAlive) { _thread.Abort(); } } catch { } _thread = null; } }
public void Stop(HomeSimCockpitSDK.StartStopType stopType) { if (!_working) { return; } _working = false; // inicjalizacja zmiennych foreach (KeyValuePair <string, IOutputVariable> kvp in _registered) { kvp.Value.Uninitialize(); } // uninicjalizacja urządzeń if (_devices != null) { for (int i = 0; i < _devices.Length; i++) { _devices[i].Uninitialize(); } _devices = null; } // zamknięcie interfejsów if (_interfaces != null) { for (int i = 0; i < _interfaces.Length; i++) { _interfaces[i].Close(_configuration); } _interfaces = null; } _log.Log(this, "Zamknięto simOUT"); }
public void Start(HomeSimCockpitSDK.StartStopType startStopType) { StopReader(); // sprawdzenie czy są jakieś timery List <RSS> rsss = new List <RSS>(); for (int i = 0; i < _rsss.Length; i++) { _rsss[i].Module = this; _rsss[i].Log = _log; _rsss[i].Reset(); if (_rsss[i].IsSubscribed) { rsss.Add(_rsss[i]); } } _subscribedRSS = rsss.ToArray(); if (_subscribedRSS.Length > 0) { StartReader(); } }
public void Start(HomeSimCockpitSDK.StartStopType StartStartStopType) { // nie ma żadnych zmiennych więc nie trzeba nic robić if (_variables == null || _variables.Length == 0) { return; } // wyczyszczenie słowników _inputsDictionary.Clear(); _registeredVariables.Clear(); // sprawdzenie czy są zmienne z zarejestrowanymi "słuchaczami" foreach (PMDGVariable input in _variables) { if (input.IsListenerRegistered) { input.Module = this; input.Reset(); input.FirstSet(); _registeredVariables.Add(input); // uint key = 0; // switch (input.Type) // { // case HomeSimCockpitSDK.VariableType.Bool: // key = BOOL_FLAG | input.FSXGroup; // break; // // case HomeSimCockpitSDK.VariableType.Int: // key = INT_FLAG | input.FSXGroup; // break; // // case HomeSimCockpitSDK.VariableType.Double: // key = DOUBLE_FLAG | input.FSXGroup; // break; // // case HomeSimCockpitSDK.VariableType.String: // key = STRING_FLAG | input.FSXGroup; // break; // } // if (!_inputsDictionary.ContainsKey(key)) // { // _inputsDictionary[key] = new List<FSXInput>(); // } // _inputsDictionary[key].Add(input); } } if (_registeredVariables.Count == 0) { // nie ma żadnych zmiennych zarejestrowanych więc nie ma nic do roboty return; } // połączenie z FSX _working = true; OpenSimConnect(); //_simconnect.RegisterDataDefineStruct<PMDG.PMDG_NGX_Data>(PMDG.PMDGEnum.PMDG_NGX_DATA_DEFINITION); _simconnect.MapClientDataNameToID(PMDG.PMDG737NGXSDK.PMDG_NGX_DATA_NAME, PMDG.PMDGEnum.PMDG_NGX_DATA_ID); _simconnect.AddToClientDataDefinition(PMDG.PMDGEnum.PMDG_NGX_DATA_DEFINITION, 0, (uint)Marshal.SizeOf(typeof(PMDG.PMDG_NGX_Data)), 0, 0); _simconnect.RequestClientData(PMDG.PMDGEnum.PMDG_NGX_DATA_ID, PMDG.PMDGEnum.DATA_REQUEST, PMDG.PMDGEnum.PMDG_NGX_DATA_DEFINITION, SIMCONNECT_CLIENT_DATA_PERIOD.ON_SET, SIMCONNECT_CLIENT_DATA_REQUEST_FLAG.CHANGED, 0, 0, 0); _simconnect.RegisterStruct <SIMCONNECT_RECV_CLIENT_DATA, PMDG.PMDG_NGX_Data>(PMDG.PMDGEnum.PMDG_NGX_DATA_DEFINITION); //_simconnect.RegisterStruct<SIMCONNECT_RECV, PMDG.PMDG_NGX_Data>(PMDG.PMDGEnum.PMDG_NGX_DATA_DEFINITION); // // pobranie metody "RegisterDataDefineStruct" // Type simConnectType = _simconnect.GetType(); // // // utworzenie Assembly i Module // AssemblyBuilder asmBuilder = null; // ModuleBuilder modBuilder = null; // AssemblyName assemblyName = new AssemblyName(); // assemblyName.Name = "DynamicStructs"; // AppDomain thisDomain = Thread.GetDomain(); // asmBuilder = thisDomain.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.Run); // modBuilder = asmBuilder.DefineDynamicModule(asmBuilder.GetName().Name, false); // // // utworzenie dynamicznie struktur do odbierania danych // foreach (KeyValuePair<uint, List<FSXInput>> kvp in _inputsDictionary) // { // int index = 0; // uint structId = kvp.Key; // TypeBuilder typeBuilder = modBuilder.DefineType("Struct_bool_" + kvp.Key.ToString(), TypeAttributes.Public | TypeAttributes.AutoClass | TypeAttributes.AnsiClass | TypeAttributes.BeforeFieldInit | TypeAttributes.SequentialLayout, typeof(ValueType)); // foreach (FSXInput input in kvp.Value) // { // input._DynamicName = "field_" + (index++).ToString(); // input._DynamicValue = null; // Type t = FSXTypeToType(input.FSXType); // typeBuilder.DefineField(input._DynamicName, t, FieldAttributes.Public); // _simconnect.AddToDataDefinition((DATA_DEFINITIONS)structId, input.FSXName, FSXUnitToFSXUnitName(input.FSXUnit), input.FSXType, input.FSXEpsilon, SimConnect.SIMCONNECT_UNUSED); // } // Type structType = typeBuilder.CreateType(); // MethodInfo dynamicMethod = _simconnect.GetType().GetMethod("RegisterDataDefineStruct").MakeGenericMethod(new Type[] { structType }); // dynamicMethod.Invoke(_simconnect, new object[] { (DATA_DEFINITIONS)structId }); // // _simconnect.RequestDataOnSimObject((DATA_REQUESTS)(structId | FIRST_REQUEST_FLAG), (DATA_DEFINITIONS)structId, SimConnect.SIMCONNECT_OBJECT_ID_USER, SIMCONNECT_PERIOD.ONCE, SIMCONNECT_DATA_REQUEST_FLAG.DEFAULT, 0, 0, 0); // _simconnect.RequestDataOnSimObject((DATA_REQUESTS)structId, (DATA_DEFINITIONS)structId, SimConnect.SIMCONNECT_OBJECT_ID_USER, SIMCONNECT_PERIOD.SIM_FRAME, SIMCONNECT_DATA_REQUEST_FLAG.CHANGED, 0, 0, 0); // } // wystartowanie wątka // (w wątku jednorazowane pobranie wartości // i żądanie uaktualnień wartości gdy się zmienią) //throw new NotImplementedException(); }
public void Start(HomeSimCockpitSDK.StartStopType startStopType) { Stop(HomeSimCockpitSDK.StartStopType.Output); _joysticks.Clear(); }
public void Stop(HomeSimCockpitSDK.StartStopType startStopType) { StopTimers(); }
public void Start(HomeSimCockpitSDK.StartStopType StartStartStopType) { Stop(StartStartStopType); }
public void Start(HomeSimCockpitSDK.StartStopType startType) { Stop(startType); // próba otworzenia połączenia z RS232 _working = true; if (_registered.Count == 0 && !_requireFunction) { return; } _motors.Clear(); _servos.Clear(); // sprawdzenie które interfejsy trzeba uruchomić List <RS232Configuration> interfaces = new List <RS232Configuration>(); List <Device> devices = new List <Device>(); foreach (KeyValuePair <string, IOutputVariable> kvp in _registered) { Device[] ints = kvp.Value.Devices; foreach (Device inte in ints) { if (interfaces.Find(delegate(RS232Configuration o) { return(o.Id == inte.Interface.Id); }) == null) { interfaces.Add(inte.Interface); inte.Interface.Log = _log; inte.Interface.Module = this; } if (devices.Find(delegate(Device o) { return(o.Id == inte.Id); }) == null) { devices.Add(inte); } } } if (_runSteppers) { foreach (StepperDevice stepperDevice in _configuration.StepperDevices) { if (interfaces.Find(delegate(RS232Configuration o) { return(o.Id == stepperDevice.Interface.Id); }) == null) { interfaces.Add(stepperDevice.Interface); stepperDevice.Interface.Log = _log; stepperDevice.Interface.Module = this; } if (devices.Find(delegate(Device o) { return(o.Id == stepperDevice.Id); }) == null) { devices.Add(stepperDevice); if (stepperDevice.Motor1 != null && !string.IsNullOrEmpty(stepperDevice.Motor1.Id)) { if (!_motors.ContainsKey(stepperDevice.Motor1.Id)) { _motors.Add(stepperDevice.Motor1.Id, stepperDevice.Motor1); } } if (stepperDevice.Motor2 != null && !string.IsNullOrEmpty(stepperDevice.Motor2.Id)) { if (!_motors.ContainsKey(stepperDevice.Motor2.Id)) { _motors.Add(stepperDevice.Motor2.Id, stepperDevice.Motor2); } } } } } if (_runServos) { foreach (ServoDevice servoDevice in _configuration.ServoDevices) { if (interfaces.Find(delegate(RS232Configuration o) { return(o.Id == servoDevice.Interface.Id); }) == null) { interfaces.Add(servoDevice.Interface); servoDevice.Interface.Log = _log; servoDevice.Interface.Module = this; } if (devices.Find(delegate(Device o) { return(o.Id == servoDevice.Id); }) == null) { devices.Add(servoDevice); foreach (Servo servo in servoDevice.Servos) { if (!string.IsNullOrEmpty(servo.Id) && !_servos.ContainsKey(servo.Id)) { _servos.Add(servo.Id, servo); } } } } } _interfaces = interfaces.ToArray(); _devices = devices.ToArray(); // otwarcie potrzebnych interfejsów for (int i = 0; i < _interfaces.Length; i++) { _interfaces[i].Open(); } // inicjalizacja urządzeń for (int j = 0; j < _devices.Length; j++) { if (_devices[j] is LEDDisplayDevice) { ((LEDDisplayDevice)_devices[j]).Dictionary = _configuration.LEDDisplaysDictionary; } _devices[j].Initialize(); } // inicjalizacja zmiennych foreach (KeyValuePair <string, IOutputVariable> kvp in _registered) { if (kvp.Value is LEDDisplay) { ((LEDDisplay)kvp.Value).Dictionary = _configuration.LEDDisplaysDictionary; } if (kvp.Value is LEDDisplayGroup) { ((LEDDisplayGroup)kvp.Value).Dictionary = _configuration.LEDDisplaysDictionary; } kvp.Value.Initialize(); } _log.Log(this, "Uruchomiono simOUT"); }
public void Stop(HomeSimCockpitSDK.StartStopType StartStopType) { StopServer(); }
public void Start(HomeSimCockpitSDK.StartStopType startStopType) { if (_working) { return; } Stop(startStopType); // pobranie listy interfejsów RS do nasłuchu _deviceKeys.Clear(); Dictionary <RS232Configuration, List <simINDevice> > interf = new Dictionary <RS232Configuration, List <simINDevice> >(); foreach (Key key in LoadConfiguration().Keys) { if (!key.IsSubscribed) { continue; } RS232Configuration interfac = key.KeysDevice.Interface; if (!interf.ContainsKey(interfac)) { interf.Add(interfac, new List <simINDevice>()); } if (!interf[interfac].Contains(key.KeysDevice)) { interf[interfac].Add(key.KeysDevice); } key.Module = this; key.Reset(); if (!_deviceKeys.ContainsKey(key.KeysDevice)) { _deviceKeys.Add(key.KeysDevice, new List <Key>()); } _deviceKeys[key.KeysDevice].Add(key); } if (_deviceKeys.Count == 0) { return; } _devices.Clear(); foreach (KeyValuePair <RS232Configuration, List <simINDevice> > kvp in interf) { if (kvp.Value.Count > 0) { _devices.Add(new simINDevices(LoadConfiguration(), kvp.Key, kvp.Value.ToArray())); } } foreach (KeysDevice keysDevice in LoadConfiguration().KeysDevices) { List <Encoder> encoders = new List <Encoder>(); if (LoadConfiguration().Encoders != null) { foreach (Encoder enc in LoadConfiguration().Encoders) { if (enc.KeysDevice == keysDevice) { encoders.Add(enc); } } } keysDevice.Encoders = encoders.ToArray(); } _working = true; foreach (simINDevices simin in _devices) { simin.ReceivedReportEvent += new ReceivedReportDelegate(simin_ReceivedReportEvent); simin.Start(); } }
public void Stop(HomeSimCockpitSDK.StartStopType StartStopType) { _working = false; CloseSimConnect(); }
public void Stop(HomeSimCockpitSDK.StartStopType startStopType) { _working = false; }