Exemplo n.º 1
0
 private void RaiseAnswerRecieved(BaseAnswerEventArgs eventArgs)
 {
     if (AnswerRecieved != null)
         AnswerRecieved(this, eventArgs);
 }
Exemplo n.º 2
0
 private void OnAnswerRecieved(object sender, BaseAnswerEventArgs e)
 {
     if (e is StepPositionRecievedEventArgs)
         Position = ((StepPositionRecievedEventArgs)e).StepPosition;
     else if (e is ConnectionEstablishedEventArgs)
         SetHome();
 }
Exemplo n.º 3
0
        private void OnAnswerRecieved(object sender, BaseAnswerEventArgs e)
        {
            if (e is SensorValueRecievedEventArgs)
            {
                var valueInfo = (SensorValueRecievedEventArgs)e;

                if (valueInfo.Sensor1 == -1)
                {
                    SynchronisationHelper.Synchronise(() => Sensor1 = SENSOR_NOT_AVALIABLE);
                    SynchronisationHelper.Synchronise(() => Sensor2 = SENSOR_NOT_AVALIABLE);
                }
                else
                {
                    SynchronisationHelper.Synchronise(() => Sensor1 = valueInfo.Sensor1.ToString("F1"));
                    SynchronisationHelper.Synchronise(() => Sensor2 = valueInfo.Sensor2.ToString("F1"));
                }
                if (SensorValueRecieved != null)
                    SensorValueRecieved(this, valueInfo);
            }
            if (e is TemperatureRecievedEventArgs)
            {
                TemperatureRecievedEventArgs temperatureRecievedEventArgs = (TemperatureRecievedEventArgs)e;
                if (temperatureRecievedEventArgs.SensorNotAvaliable)
                    SynchronisationHelper.Synchronise(() => Temperature = SENSOR_NOT_AVALIABLE);
                else if (temperatureRecievedEventArgs.ValueNotReady)
                    SynchronisationHelper.Synchronise(() => Temperature = DATA_NOT_READY);
                else
                    SynchronisationHelper.Synchronise(() => Temperature = temperatureRecievedEventArgs.Temperature.ToString("F1"));
            }
            else if (e is AddressRecievedEventArgs)
            {
                var addressInfo = (AddressRecievedEventArgs)e;
                if (addressInfo.Address == -1)
                {
                    SynchronisationHelper.Synchronise(() => SelectedSensor = null);
                    SynchronisationHelper.ShowMessage("На выбраном канале датчик отсутствует", "Внимание!", MessageBoxButton.OK, MessageBoxImage.Information);
                }
                else
                    SynchronisationHelper.Synchronise(() =>
                        SelectedSensor = _DataBaseManager.GetSensor(SelectedSensorNumber.Value, addressInfo.Address));
            }
        }