public void insertRecord(WATR_SensorRecord record)
        {
            batteryPercentStatusLabel.Text = record.BatteryLevel.ToString() + "%";
            temperatureTextBox.Text = record.Temperature.ToString();
            humidityTextBox.Text = record.Humidity.ToString();
            moistureLevelTextBox.Text = record.MoistureLevel.ToString();
            lastUpdateDateLabel.Text = record.TimeStamp.ToString();

            //Re-enable the refresh button if it's disabled
            this.forceRefreshButton.Enabled = true;
        }
Beispiel #2
0
 public void SetRecord(WATR_SensorRecord record)
 {
     //Insert the record
     if (form.InvokeRequired)
     {
         form.Invoke(new Action<WATR_SensorRecord>(SetRecord), record);
     }
     else
     {
         form.insertRecord(record);
     }
 }
        //Parse an incoming temperature record
        private void parseRFDataTemperatureRecord(ulong source, byte[] rf)
        {
            string rfData = rf.ConvertToString(customPacketDataStart);

            //Simple error check - the temp record should -NEVER- be less than 5 bytes. EVER.
            if (rfData.Length < 5)
                return;

            //Get the temperature
            //Math: The index of the first "T", add one so we don't include the T
            //Then, the length is the lower 't' position subtracting the upper-case T's location
            //So if we have "T".loc = 3 and "t".loc = 8
            //We start at position 3 + 1 = 4 for the first part of the temperature
            //Then copy until 8 - 3 = 5 - 1 = 4 (because of the fact that "T" is actually one more letter than we need)
            int temperature = Convert.ToInt32(rfData.Substring(rfData.IndexOf('T') + 1, rfData.IndexOf('t') - rfData.IndexOf('T') - 1));

            //The rest of the records follow the same logic
            int humidity = Convert.ToInt32(rfData.Substring(rfData.IndexOf('H') + 1, rfData.IndexOf('h') - rfData.IndexOf('H') - 1));
            int moisture = Convert.ToInt32(rfData.Substring(rfData.IndexOf('M') + 1, rfData.IndexOf('m') - rfData.IndexOf('M') - 1));
            int battery = Convert.ToInt32(rfData.Substring(rfData.IndexOf('B') + 1, rfData.IndexOf('b') - rfData.IndexOf('B') - 1));

            //Create a record
            WATR_SensorRecord record = new WATR_SensorRecord(source, temperature, humidity, moisture, battery);

            //Raise an event
            WATR_SensorRecordGetArgs getRecord = new WATR_SensorRecordGetArgs(record);
            if (getRecord != null)
                SensorRecordGet(this, getRecord);
        }
 public WATR_SensorRecordGetArgs(WATR_SensorRecord record)
 {
     SensorRecord = record;
 }
Beispiel #5
0
 public void LogSensorRecord(WATR_SensorRecord record)
 {
     string cmd = "INSERT INTO SensorInfo_T VALUES (" + record.SourceAddress.ToString() + "," + record.Temperature.ToString() + ","
         + record.Humidity.ToString() + "," + record.MoistureLevel.ToString() + "," + record.BatteryLevel.ToString() + ","
         + "'" +record.TimeStamp.ToString("yyyy-MM-dd HH:mm:ss") + "');";
     executeRawSQL(cmd);
 }