示例#1
0
        public MainPage()
        {
            this.InitializeComponent();

            _physicalFL = new FileLogger(PHYSICAL_LOG_FILE_NAME);
            _masterFL   = new FileLogger(MASTER_LOG_FILE_NAME);

            _converter = new MCP3208ADC(SERIAL_NUMBER);

            _shiftR = new ShiftRegister(SHIFT_REGISTER_BUS_LENGHT, DATA_SHIFT_REGISTER_PIN, CLOCK_SHIFT_REGISTER_PIN, LATCH_SHIFT_REGISTER_PIN);
            _lcd    = new LCD(_shiftR, LCD_BIT0_PIN, LCD_BIT1_PIN, LCD_BIT2_PIN, LCD_BIT3_PIN, LCD_ENABLE_PIN, LCD_REGISTER_SELECT_PIN);

            _sensori = new SensoreAnalogico[]
            {
                new SensoreLuminosita(_converter, LUM_SHIFT_NUMBER),
                new SensoreCO2(_converter, CO2_SHIFT_NUMBER),
                new SensoreUmiditaAria(_converter, UA_SHIFT_NUMBER),
                new SensoreUmiditaTerreno(_converter, UT_SHIFT_NUMBER),
                new SensoreTemperatura(_converter, TEMP_SHIFT_NUMBER)
            };

            _printStatus.Interval = TimeSpan.FromMilliseconds(CHANGE_STATUS_MILLISECONDS_TIMER);
            _printStatus.Tick    += PrintStatus_Tick;
            _printStatus.Start();

            _lightFence                = new StepperMotorDevice("Blinding Fence", _shiftR, A1_STEPPER_PIN, A2_STEPPER_PIN, B1_STEPPER_PIN, B2_STEPPER_PIN, STOP_ORARIO_PIN, STOP_ANTIORARIO_PIN);
            _lightFence.WriteLog      += WritePhysicalLogAsync;
            _lightBulb                 = new OnOffDevice("Agro Light Bulb", _shiftR, LIGHT_BULB_PIN);
            _lightBulb.WriteLog       += WritePhysicalLogAsync;
            _lightController           = new LightController("Light Controller", _lightFence, _lightBulb);
            _lightController.WriteLog += WriteMasterLogAsync;

            _heatResistor           = new PwmDevice("Heat Resistor", HEAT_RES_PIN);
            _heatResistor.WriteLog += WritePhysicalLogAsync;

            _airCicleFan           = new PwmDevice("Air Circle Fan", AIR_CIRLE_FAN_PIN);
            _airCicleFan.WriteLog += WritePhysicalLogAsync;

            _airCicleFan.ChangeDutyCycle(50);
            _airCicleFan.Start();
            _heatResistor.ChangeDutyCycle(50);
            _heatResistor.Start();
            Task.Delay(1000).Wait();
            _airCicleFan.Stop();
            _heatResistor.Stop();

            txtStatus.Text = "Running...";
        }
示例#2
0
 private const double DC_GAIN = 8.5;              //define the DC gain of amplifier
 public SensoreCO2(MCP3208ADC c, int n) : base(c, n)
 {
 }
示例#3
0
 private const double MAXVOLT = 3.3;    // Max volt secco
 public SensoreUmiditaTerreno(MCP3208ADC c, int n) : base(c, n)
 {
 }
 public SensoreLuminosita(MCP3208ADC c, int n) : base(c, n)
 {
 }
 public SensoreTemperatura(MCP3208ADC c, int n) : base(c, n)
 {
 }
 public SensoreAnalogico(MCP3208ADC c, int ch)
 {
     _converter     = c;
     CHANNEL_NUMBER = ch;
 }
示例#7
0
 public SensoreUmiditaAria(MCP3208ADC c, int n) : base(c, n)
 {
 }