Ejemplo n.º 1
0
        public async Task <bool> Post([FromBody] OpenCloseCommandDto openCloseCommandDto)
        {
            var arduinoService = new ArduinoService(_db);
            await arduinoService.SendOpenCLoseCommand(openCloseCommandDto);

            return(true);
        }
        // GET: ArduinoStationsMvc/Details/5
        public async Task <IActionResult> Details(int?id, [FromQuery] bool?waterStatus)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var arduinoStation = await _context.ArduinoStations.AsNoTracking().SingleOrDefaultAsync(m => m.Id == id);

            if (waterStatus.HasValue)
            {
                var arduinoService = new ArduinoService(_context);
                var sss            = new Models.Dto.OpenCloseCommandDto()
                {
                    StationId = id.Value, StationStatus = waterStatus.Value
                };
                await arduinoService.SendOpenCLoseCommand(sss);
            }
            if (arduinoStation == null)
            {
                return(NotFound());
            }

            return(View(arduinoStation));
        }
Ejemplo n.º 3
0
        public async Task StartListener(string comPort)
        {
            Func <string, Task> sendMessageCallback = SendMessage;

            try
            {
                using (var arduino = new ArduinoService(comPort, sendMessageCallback))
                { }
            }
            catch (Exception e)
            {
                await SendMessage(e.Message);
            }
        }
Ejemplo n.º 4
0
        public OpenCVService(ArduinoService arduinoService, ConfigService configService, Logger logger)
        {
            _arduinoService = arduinoService;
            _configService  = configService;
            _logger         = logger;

            var hHigh = _configService.Config.HSLSkinHigh;
            var hLow  = _configService.Config.HSLSkinLow;


            var h_high = (byte)(hHigh[0] / 2);
            var s_high = (byte)((double)hHigh[1] / 100 * 255);
            var l_high = (byte)((double)hHigh[2] / 100 * 255);

            var h_low = (byte)(hLow[0] / 2);
            var s_low = (byte)((double)hLow[1] / 100 * 255);
            var l_low = (byte)((double)hLow[2] / 100 * 255);

            SkinUpper = new Vec3b(h_high, s_high, l_high);
            SkinLower = new Vec3b(h_low, s_low, l_low);
        }
 private void SetupArduino()
 {
     arduino = new ArduinoService("COM3", 9600);
     arduino.OnInitialisedSuccessHandler += ArduinoInitialisedSuccessHandler;
     arduino.OnInitialisedFailedHandler  += ArduinoInitialisedFailedHandler;
 }