Пример #1
0
        public Form1()
        {
            XmlConfigurator.Configure();
            logger.Info("Start MeteoChase500DiverTestApplication, version 2012_Feb_27");
            InitializeComponent();
            this.labelMaxHumidity.Text  = "Max Hum = " + (WeatherAnalisis.MaxHumidity * 100) + " %";
            this.labelMaxWindSpeed.Text = "Max Wind Speed = " + WeatherAnalisis.MaxWindSpeed_inKnots;
            this.labelMinDewPoint.Text  = "Min Dew Point Delta = " + WeatherAnalisis.MinDewPointDelta + " [ºC]";

            sm = new SafetyMonitor();
            this.timerRefresh.Start();
            this.refresh();
            logger.Info("End");
        }
Пример #2
0
        public T CreateDeviceInstance <T>(DeviceConfiguration configuration) where T : IDevice
        {
            Type deviceType = typeof(T);

            switch (deviceType.Name)
            {
            case nameof(FilterWheel):
                IDevice device = new FilterWheel(configuration, _clientTransactionIdGenerator);
                return((T)device);

            case nameof(SafetyMonitor):
                IDevice safetyMonitor = new SafetyMonitor(configuration, _clientTransactionIdGenerator);
                return((T)safetyMonitor);

            case nameof(Dome):
                IDevice dome = new Dome(configuration, _clientTransactionIdGenerator);
                return((T)dome);

            case nameof(Camera):
                IDevice camera = new Camera(configuration, _clientTransactionIdGenerator);
                return((T)camera);

            case nameof(Focuser):
                IDevice focuser = new Focuser(configuration, _clientTransactionIdGenerator);
                return((T)focuser);

            case nameof(ObservingConditions):
                IDevice observingConditions = new ObservingConditions(configuration, _clientTransactionIdGenerator);
                return((T)observingConditions);

            case nameof(Rotator):
                IDevice rotator = new Rotator(configuration, _clientTransactionIdGenerator);
                return((T)rotator);

            case nameof(Switch):
                IDevice @switch = new Switch(configuration, _clientTransactionIdGenerator);
                return((T)@switch);

            case nameof(Telescope):
                IDevice telescope = new Telescope(configuration, _clientTransactionIdGenerator);
                return((T)telescope);

            default:
                throw new InvalidOperationException($"Type {deviceType.Name} is not supported");
            }
        }
        private void Connect()
        {
            if (!String.IsNullOrEmpty(observingConditionsID))
            {
                try
                {
                    oObservingConditions = new ObservingConditions(observingConditionsID)
                    {
                        Connected = true
                    };
                }
                catch (Exception ex)
                {
                    String msg = ex.Message;
                    if (ex.InnerException != null)
                    {
                        msg += " - " + ex.InnerException.Message;
                    }
                    MessageBox.Show(string.Format("Connect failed with error {0}", msg));
                }
            }

            if (!String.IsNullOrEmpty(safetyMonitorID))
            {
                try
                {
                    oSafetyMonitor = new SafetyMonitor(safetyMonitorID)
                    {
                        Connected = true
                    };
                }
                catch (Exception ex)
                {
                    String msg = ex.Message;
                    if (ex.InnerException != null)
                    {
                        msg += " - " + ex.InnerException.Message;
                    }
                    MessageBox.Show(string.Format("Connect failed with error {0}", msg));
                }
            }
        }
Пример #4
0
        public async Task IsSafeAsync_SendValidRequest()
        {
            //Arrange
            string       commandName       = "issafe";
            IRestRequest sentRequest       = null;
            var          commandSenderMock = new Mock <ICommandSender>();

            commandSenderMock
            .Setup(x => x.ExecuteRequestAsync <BoolResponse>(It.IsAny <string>(), It.IsAny <RestRequest>()))
            .Callback((string baseUrl, IRestRequest request) => sentRequest = request)
            .Returns(Task.FromResult(new BoolResponse(false)));
            var safetyMonitor = new SafetyMonitor(_deviceConfiguration, commandSenderMock.Object);

            //Act
            await safetyMonitor.IsSafeAsync();

            //Assert
            Assert.Equal(Method.GET, sentRequest.Method);
            AssertCommonParameters(sentRequest.Parameters, _deviceConfiguration, commandName);
        }
 private void Button_Click_1(object sender, RoutedEventArgs e)
 {
     if (oSafetyMonitor != null && oSafetyMonitor.Connected)
     {
         return;
     }
     try
     {
         safetyMonitorID = SafetyMonitor.Choose(safetyMonitorID);
         oProfile.WriteValue(profileID, "safetyMonitorID", safetyMonitorID);
     }
     catch (Exception ex)
     {
         String msg = ex.Message;
         if (ex.InnerException != null)
         {
             msg += " - " + ex.InnerException.Message;
         }
         MessageBox.Show(string.Format("Choose failed with error {0}", msg));
     }
 }
Пример #6
0
 public Form1()
 {
     monitor = new SafetyMonitor();
     InitializeComponent();
 }
Пример #7
0
 public SafetyMonitorSpecificMethodsApiTests()
 {
     instance = new SafetyMonitor("http://localhost:5000/api/v1/");
 }