예제 #1
0
        static void Main(string[] args)
        {
            weatherStation = new WeatherStation();

            // create few sensores
            // List<Sensor> sensorList = new List<Sensor>();

            HumidityTempratureSensor hs  = new HumidityTempratureSensor();
            TemperatureSensor        ts  = new TemperatureSensor();
            TemperatureSensor        ts1 = new TemperatureSensor();
            PressureSensor           ps  = new PressureSensor();

            ServerShouldRun = true;
            (new Thread(StartServerProc)).Start();

            // Take measurements
            ps.TakeMeasurements();
            hs.TakeMeasurements();
            ts1.TakeMeasurements();
            ts.TakeMeasurements();

            Console.WriteLine("Press \'q\' to quit the sample.");
            while (Console.Read() != 'q')
            {
                ;
            }
            ServerShouldRun = false;
        }
예제 #2
0
        public static void Main(string[] args)
        {
            Sensor sensor = new Sensor();
            //---------------------------------------------------------
            TemperatureSensor tSensor = new TemperatureSensor {
                degrees = "C", temperature = 30, Name = "sensor Temp"
            };

            WeatherStation weatherStation = new WeatherStation();

            weatherStation.addSensor(tSensor);

            tSensor.sensorEvent += weatherStation.subscribeMeasurement;
            tSensor.addMeasurement("temp", tSensor.temperature);

            //-----------------------------------------------------------
//            PressureSensor pSensor = new PressureSensor { pressure = 21 };
//            WeatherStation weatherStation2 = new WeatherStation();
//
//            tSensor.sensorEvent += weatherStation2.subscribeMeasurement;
//            tSensor.addMeasurement("pres", tSensor.temperature);


//            Console.WriteLine(tSensor.);


            //--------------------------------------------------------------

//            weatherStation.addSensor(sensor);

//            Sensor sensorTest = new PressureSensor {pressure = 1222};
//            Sensor sensorTest2 = new TemperatureSensor() {temperature = 35};
//            weatherStation.addSensor(sensorTest);
//            weatherStation.addSensor(sensorTest2);

//            Console.WriteLine("---------------------------");
//            weatherStation.getSenor("pressure");
//
//            Console.WriteLine("\n--------------------------");
//            List<ITemperature> SensorList = weatherStation.getSensorBySpecyficValue(10);
//            foreach (var temperature in SensorList)
//            {
//                Console.WriteLine(temperature);
//
//            }
            Connect(convertToJSON(weatherStation));

            Console.WriteLine("Press any key to exit.");
            Console.ReadKey();
        }