Exemplo n.º 1
0
        //Get Breathanalyzer value from Arduino
        public string GetBreathResult()
        {
            if (IsArduinoPortOpened())
            {
                QueryString query = new QueryString(Device.BREATH, ProtocolDef.GET_BREATH);
                WriteToSerial(query.ToString());

                return ReadFromSerial();    // 0 pass 1 fail -1 try again
            }
            return ProtocolDef.SERIALPORT_NOT_OPENED_ERROR;
        }
Exemplo n.º 2
0
        //Get Magnetic Strip Reading from Arduino
        public int GetCardReading()
        {
            if (IsArduinoPortOpened())
            {
                QueryString query = new QueryString(Device.CARDREADER, ProtocolDef.GET_CARDREADER);
                WriteToSerial(query.ToString());

                try
                {
                    return int.Parse(ReadFromSerial());
                }
                catch //(Exception ex)
                {

                }
            }
            return 1;
        }
Exemplo n.º 3
0
        //TestLED from Arduino
        public int TestLED(int delay, int forcereturn)
        {
            if (IsArduinoPortOpened())
            {
                QueryString query = new QueryString(Device.TEST_DEVICE, ProtocolDef.TEST_LED);
                query.SubQueries.Add(delay.ToString());
                query.SubQueries.Add(forcereturn.ToString());

                try
                {
                    return int.Parse(ReadFromSerial());
                }
                catch //(Exception ex)
                {

                }
            }
            return 1;
        }
Exemplo n.º 4
0
        public string PumpOn(int pumpNum, int interval)
        {
            if (IsArduinoPortOpened())
            {
                QueryString query = new QueryString(Device.PUMP, ProtocolDef.SET_MOTOR);
                query.SubQueries.Add(pumpNum.ToString());
                query.SubQueries.Add(ProtocolDef.ON);
                query.SubQueries.Add(interval.ToString());

                WriteToSerial(query.ToString());

                try
                {
                    //debugging
                    string temp1 = ReadFromSerial();
                    int success = int.Parse(temp1);
                    if (success == 0)
                        return ProtocolDef.SUCCESS;

                    return ProtocolDef.SERIALPORT_READ_ERROR;
                }
                catch //(Exception ex)
                {
                    return ProtocolDef.SERIALPORT_READ_ERROR;
                }
            }
            return ProtocolDef.SERIALPORT_NOT_OPENED_ERROR;
        }
Exemplo n.º 5
0
        public string PumpOff(int pumpNum)
        {
            if (IsArduinoPortOpened())
            {
                QueryString query = new QueryString(Device.PUMP, ProtocolDef.SET_MOTOR);
                query.SubQueries.Add(pumpNum.ToString());
                query.SubQueries.Add(ProtocolDef.OFF);
                query.SubQueries.Add("0");

                WriteToSerial(query.ToString());

                try
                {
                    if (int.Parse(ReadFromSerial()) == 0)
                        return ProtocolDef.SUCCESS;
                }
                catch //(Exception ex)
                {
                    return ProtocolDef.SERIALPORT_READ_ERROR;;
                }
            }
            return ProtocolDef.SERIALPORT_NOT_OPENED_ERROR;
        }
Exemplo n.º 6
0
        //Get Force Sensor Reading from Arduino
        public string GetForceSensorResult()
        {
            if (IsArduinoPortOpened())
            {
                QueryString query = new QueryString(Device.FORCESENSOR, ProtocolDef.GET_FORCESENSOR);
                WriteToSerial(query.ToString());

                return ReadFromSerial();
            }
            return "1";
        }