public void EventTypeIsUnknowWhenRowIsInvalid()
        {
            string row = "???SDFSDŁ$Ł¤>-";
            var eventArg = new SolarCollectorEventArg(row);

            Assert.That(eventArg.Type, Is.EqualTo(EventType.Unknown));
        }
Beispiel #2
0
        private void CommunicationInterfaceSolarEvent(object sender, SolarCollectorEventArg e)
        {
            var sensor = e as SolarCollectorSensorEventArg;
            if (sensor != null)
            {
                _dbHandler.AddDataEvent(sensor.RaisedAt, sensor.RaisedTime, sensor.SensorKey, sensor.SensorValue, sensor.SensorTextValue, e.Raw, e.Formatted);
            }

            _dbHandler.AddDataInfo(e.RaisedAt, e.RaisedTime, e.Raw, e.Type, e.Formatted);

            if (e.Type == EventType.GetSetting)
            {
                AnswerSetting(e as SolarCollectorSettingEventArg);
            }
        }
        public void RaisedTimeSetTo0_WhenTimeValueIsIncorrect()
        {
            var row = "TIME:5??11 INFO: STOP";
            var now = DateTime.Now;

            var eventArg = new SolarCollectorEventArg(row);

            Assert.That(eventArg.RaisedTime, Is.EqualTo(0));

            Assert.That(eventArg.RaisedAt, Is.InRange(now.AddSeconds(-1), now.AddSeconds(1)));
        }
        public void RaisedTimeComeFromString(string row, int expectedValue)
        {
            var now = DateTime.Now;

            var eventArg = new SolarCollectorEventArg(row);

            Assert.That(eventArg.RaisedTime, Is.EqualTo(expectedValue));

            Assert.That(eventArg.RaisedAt, Is.InRange(now.AddSeconds(-1), now.AddSeconds(1)));
        }
        public void EventTypeReqGetTimeIsCorrect(string row)
        {
            var eventArg = new SolarCollectorEventArg(row);

            Assert.That(eventArg.Type, Is.EqualTo(EventType.GetTime));
        }
        public void EventTypeInfoSettingIsCorrect(string row)
        {
            var eventArg = new SolarCollectorEventArg(row);

            Assert.That(eventArg.Type, Is.EqualTo(EventType.Info));
        }
 public void RawDataEqualToGivenValue(string row)
 {
     var eventArg = new SolarCollectorEventArg(row);
     Assert.That(eventArg.Raw, Is.EqualTo(row));
 }
Beispiel #8
0
        private void CommunicationInterfaceSolarEvent(object sender, SolarCollectorEventArg e)
        {
            switch (e.Type)
            {
                case EventType.GetTemp:
                    var tempEvent = e as SolarCollectorTempEventArg;
                    if (tempEvent != null)
                    {
                        switch (tempEvent.TempKey)
                        {
                            case 72:
                                _communicationInterface.SetTemp((int) inpCollectorActual.Value);
                                break;
                            case 73:
                                _communicationInterface.SetTemp((int) inpBoilerBottomActual.Value);
                                break;
                            case 74:
                                _communicationInterface.SetTemp((int) inpBoilerTopActual.Value);
                                break;
                            default:
                                _communicationInterface.SetTemp((int) inpCollectorActual.Value);
                                break;
                        }
                    }
                    return;
                case EventType.GetTime:
                    _communicationInterface.SetTime(DateTime.Now);
                    break;
                case EventType.GetSetting:
                    var settingEvent = e as SolarCollectorSettingEventArg;
                    if (settingEvent != null)
                    {
                        switch (settingEvent.SettingKey)
                        {
                            case Setting.DeltaEngineStopped:
                                _communicationInterface.AddSetSetting(settingEvent.SettingKey,
                                                                      Convert.ToInt32(inpDeltaEngineStopped.Value));
                                break;
                            case Setting.BoilerTop:
                                _communicationInterface.AddSetSetting(settingEvent.SettingKey, Convert.ToInt32(inpBoilerTop.Value));
                                break;
                            case Setting.SolarCollectorMin:
                                _communicationInterface.AddSetSetting(settingEvent.SettingKey,
                                                                      Convert.ToInt32(inpCollectorMin.Value));
                                break;
                            case Setting.SolarCollectorMax:
                                _communicationInterface.AddSetSetting(settingEvent.SettingKey,
                                                                      Convert.ToInt32(inpCollectorMax.Value));
                                break;
                            case Setting.DeltaEngineRunning:
                                _communicationInterface.AddSetSetting(settingEvent.SettingKey,
                                                                      Convert.ToInt32(inpDeltaEngineRunning.Value));
                                break;
                            default:
                                throw new ArgumentOutOfRangeException();
                        }
                    }

                    break;
            }

            if (_events.Count > 1000) _events.Clear();
            _events.Add(e);

            if (tbOutput.InvokeRequired)
            {
                var d = new SetTextCallback(SetOutput);
                tbOutput.Invoke(d);

                var d2 = new SetTextDataCallback(SetOutputData);
                tbOutputData.Invoke(d2, new object[] { e});

            }
            else
            {
                SetOutput();
                SetOutputData(e);
            }
        }
Beispiel #9
0
 private void SetOutputData(SolarCollectorEventArg arg)
 {
     if (arg.Type == EventType.Data)
     {
         tbOutputData.AppendText(arg.Formatted);
     }
 }