/// <summary>
            /// Retrieves the USB/Bluetooth device connected to this software.
            /// </summary>
            /// <returns>The simulator object or null.</returns>
            public CBaseSimulator GetOstererSimulator()
            {
                if (myDevice == null)
                {
                    myDevice = CSerialServer.Instance.GetConnectedSimulators().FirstOrDefault();
                }

                return(myDevice);
            }
        /// <summary>
        /// If the connection to the hardware device cannot be established or if the connection is interrupted during communication, this method is invoked.
        /// </summary>
        protected override void Simulator_NoConnectionError(CBaseSimulator sender, Exception exception)
        {
            StatusDisplay.SetTextToStatus(SimulatorInterfaces.SimulatorStati.NotConnected);

            if (!this.myDevice.Com.Connected && bWasConnected)
            {
                base.OnErrorOccured(exception);
                bSimulatorIsInUse = false;
            }
        }
Beispiel #3
0
        /// <summary>
        /// Pings each available simulator device currently connected to this software.
        /// </summary>
        void SimulatorPingTimer_Elapsed(object sender, ElapsedEventArgs e)
        {
            timerTickCnt++;

            if (this.simulatorSetupType == CBaseSimulator.SimulatorSetupTypes.OneDevice)
            {
                CBaseSimulator simulator = SimulatorController.SingleSimulatorMode.SimulatorControl.Instance.GetOstererSimulator();
                string         id        = simulator.GetDeviceId(); //retrieve the id of the device to see whether it is still connected or not
                SimulatorPingTimer.Start();
                return;
            }

            List <CBaseSimulator> Simulators = SimulatorController.MultiSimulatorMode.SimulatorControl.Instance.GetAllConnectedSimulators();

            if (Simulators == null)
            {
                SimulatorPingTimer.Start();
                return;
            }

            foreach (CBaseSimulator device in Simulators)
            {
                string id;

                if (device is SerialSimulatorServices.CSerialSimulator)
                {
                    if ((device as SerialSimulatorServices.CSerialSimulator).IsConnected)
                    {
                        if ((device as SerialSimulatorServices.CSerialSimulator).LastUsageTime < DateTime.Now.AddMinutes(-10d))
                        {
                            id = (device as SerialSimulatorServices.CSerialSimulator).GetDeviceId();
                        }
                    }
                    else if (device is NgMattApiWrapper.CngMattSimulator)
                    {
                        id = device.GetDeviceId(); //this does not actually communicate with the device as this is not needed for ngMatts
                    }
                    else
                    {
                        OnErrorOccured?.Invoke(this, "Fehler im Watchdog beim überprüfen der Simulatorverbindungen. Unbekannter Typ: " + device.GetType().ToString());
                    }
                }
            }

            SimulatorPingTimer.Start();
        }
 protected override void DeviceError(CBaseSimulator sender, Exception exception)
 {
     //  if (CAppConfig.ShowAllErrorMessages)
     StatusDisplay.SetTextToStatus(SimulatorInterfaces.SimulatorStati.Ready);
     OnErrorOccured(new Exception("Error for device with id: " + this.DeviceId, exception));
 }
Beispiel #5
0
 protected override void Simulator_NoConnectionError(CBaseSimulator sender, Exception exception)
 {
 }
Beispiel #6
0
 protected override void DeviceError(CBaseSimulator sender, Exception exception)
 {
 }