Ejemplo n.º 1
0
        private void UpdateChart(DataObjectCategory dbo, DataObjectExt dObjExt, Color lineColor)
        {
            chartValues.Series.Clear();

            if (DataObjectCapabilities.HasCapability(dbo, dObjExt.Protocol))
            {
                double min = dObjExt.GetLogItemMinValue(dbo);
                double max = dObjExt.GetLogItemMaxValue(dbo);

                if ((max - min) < 10)
                {
                    min -= 5;
                    max += 5;
                }

                Console.WriteLine("Min " + min.ToString() + " - Max: " + max.ToString());
                AddChartSerie(dObjExt.GetLogItems(dbo), dbo.Value.ToString(), lineColor, min, max);
            }

            if (chartValues.Series.Count > 0)
            {
                chartValues.DataBind();
                chartValues.Update();
            }
        }
Ejemplo n.º 2
0
        private void ShowData(DataObjectExt dobjExt)
        {
            if (dobjExt.DataAvailable)
            {
                SetLabelInformation(lblSensorOneTempValue, lblSensorOneTempMin, lblSensorOneTempMax, lblSensorOneTempMinTime, lblSensorOneTempMaxTime, dobjExt, DataObjectCategory.Temperature);
                SetLabelInformation(lblSensorOneLuxValue, lblSensorOneLuxMin, lblSensorOneLuxMax, lblSensorOneLuxMinTime, lblSensorOneLuxMaxTime, dobjExt, DataObjectCategory.LUX);
                SetLabelInformation(lblSensorOneHumidityValue, lblSensorOneHumidityValueMin, lblSensorOneHumidityValueMax, lblSensorOneHumidityValueMinTime, lblSensorOneHumidityValueMaxTime, dobjExt, DataObjectCategory.Humidity);
                SetLabelInformation(lblSensorOnePressureValue, lblSensorOnePressureMin, lblSensorOnePressureMax, lblSensorOnePressureMinTime, lblSensorOnePressureMaxTime, dobjExt, DataObjectCategory.AirPressure);
                SetLabelInformation(lblSensorHeatIndexValue, lblSensorHeatIndexMin, lblSensorHeatIndexMax, lblSensorHeatIndexMinTime, lblSensorHeatIndexMaxTime, dobjExt, DataObjectCategory.HeatIndex);
            }
            else
            {
                lblSensorOneHumidityValue.Text = "Fehler";
                lblSensorOneTempValue.Text     = "Fehler";
                if (dobjExt.Protocol == DataObjectProtocol.PROTOCOL_ONE)
                {
                    lblSensorOneLuxValue.Text      = "N/A";
                    lblSensorOnePressureValue.Text = "N/A";
                }
                else if (dobjExt.Protocol == DataObjectProtocol.PROTOCOL_TWO)
                {
                    lblSensorOneLuxValue.Text      = "N/A";
                    lblSensorOnePressureValue.Text = "Fehler";
                }
                else if (dobjExt.Protocol == DataObjectProtocol.PROTOCOL_THREE)
                {
                    lblSensorOneLuxValue.Text      = "Fehler";
                    lblSensorOnePressureValue.Text = "Fehler";
                }
            }

            lblSensorOneLastUpdated.Text = "Aktualisiert: " + Common.getCurrentDateTimeFormatted();
        }
Ejemplo n.º 3
0
 private void CheckAvailableData(DataObjectExt dobjExt)
 {
     if (dobjExt.DataAvailable)
     {
         lblSensorOne.Text = this.cboSensors.GetItemText(this.cboSensors.SelectedItem);
         ShowData(dobjExt);
     }
 }
Ejemplo n.º 4
0
        private void AddDataset(DataSource ds, DataObjectExt dobj)
        {
            switch (ds)
            {
            case DataSource.Boden: GenericAddDataToList(dataBoden, dobj, 50); break;

            case DataSource.Tisch: GenericAddDataToList(dataTisch, dobj, 50); break;
            }
        }
Ejemplo n.º 5
0
        private static string GetData(DataObjectExt dobjExt, DataObjectCategory dobjCat)
        {
            double temp = dobjExt.GetItem(dobjCat);

            if (temp == double.MinValue)
            {
                return("Keine Daten");
            }

            return(HttpUtility.HtmlEncode(temp.ToString()));
        }
Ejemplo n.º 6
0
        private void GenericAddDataToList(List <DataObjectExt> lst, DataObjectExt dobj, int maxLen)
        {
            if (maxLen < 1)
            {
                return;
            }

            lst.Add(dobj);

            while (lst.Count > maxLen)
            {
                lst.RemoveAt(0);
            }
        }
Ejemplo n.º 7
0
        private void UpdateChart(DataObjectExt dobjExt)
        {
            string             selected = this.cboChartSelection.GetItemText(this.cboChartSelection.SelectedItem);
            DataObjectCategory dobjCat  = DataObjectCategory.GetObjectCategory(selected);

            if (dobjCat != null)
            {
                if (dobjExt.GetLogItemCount(dobjCat) > 0)
                {
                    Color lineColor = GetChartColor(dobjCat);
                    UpdateChart(dobjCat, dobjExt, lineColor);
                }
            }
        }
Ejemplo n.º 8
0
        private void AddSensor(string name, string portName, bool active)
        {
            if (SensorItems.ContainsKey(name))
            {
                throw new InvalidOperationException("Key '" + name + "' existiert bereits!");
            }

            DataObjectExt dobjExt = new DataObjectExt
            {
                Name     = name,
                PortName = portName,
                Active   = active
            };

            SensorItems.Add(name, dobjExt);

            SensorItemsNames.Add(name);
        }
Ejemplo n.º 9
0
        private void CheckCabability(DataObjectExt dobjExt)
        {
            cboChartSelection.Items.Clear();


            if (DataObjectCapabilities.HasTemperature(dobjExt.Protocol))
            {
                grpBoxTemperature.Enabled = true;
                cboChartSelection.Items.Add(DataObjectCategory.Temperature.Value);
            }
            else
            {
                grpBoxTemperature.Enabled = false;
            }

            if (DataObjectCapabilities.HasAirPressure(dobjExt.Protocol))
            {
                grpBoxAirPressure.Enabled = true;
                cboChartSelection.Items.Add(DataObjectCategory.AirPressure.Value);
            }
            else
            {
                grpBoxAirPressure.Enabled = false;
            }

            if (DataObjectCapabilities.HasHeatIndex(dobjExt.Protocol))
            {
                grpBoxHeatIndex.Enabled = true;
                cboChartSelection.Items.Add(DataObjectCategory.HeatIndex.Value);
            }
            else
            {
                grpBoxHeatIndex.Enabled = false;
            }

            if (DataObjectCapabilities.HasHumidity(dobjExt.Protocol))
            {
                grpBoxHumidity.Enabled = true;
                cboChartSelection.Items.Add(DataObjectCategory.Humidity.Value);
            }
            else
            {
                grpBoxHumidity.Enabled = false;
            }

            if (DataObjectCapabilities.HasLUX(dobjExt.Protocol))
            {
                grpBoxLUX.Enabled = true;
                cboChartSelection.Items.Add(DataObjectCategory.LUX.Value);
            }
            else
            {
                grpBoxLUX.Enabled = false;
            }


            if (cboChartSelection.Items.Count > 0)
            {
                cboChartSelection.SelectedIndex = 0;
            }
        }
Ejemplo n.º 10
0
 private void SetLabelInformation(Label lblValue, Label lblMinValue, Label lblMaxValue, Label lblMinTime, Label lblMaxTime, DataObjectExt dObjExt, DataObjectCategory dobjcat)
 {
     if (dObjExt.ItemExists(dobjcat) && DataObjectCapabilities.HasCapability(dObjExt.Items[dobjcat.Value].DataObjCategory, dObjExt.Protocol))
     {
         string unit = Common.getSensorValueUnit(dObjExt.Items[dobjcat.Value].SensorType);
         lblValue.Text    = dObjExt.Items[dobjcat.Value].Value.ToString("#.#0") + unit;
         lblMinValue.Text = dObjExt.Items[dobjcat.Value].MinValue.ToString("#.#0") + unit;
         lblMaxValue.Text = dObjExt.Items[dobjcat.Value].MaxValue.ToString("#.#0") + unit;
         lblMinTime.Text  = Common.getCurrentDateTimeFormattedNoSec(dObjExt.Items[dobjcat.Value].MinTimepoint);
         lblMaxTime.Text  = Common.getCurrentDateTimeFormattedNoSec(dObjExt.Items[dobjcat.Value].MaxTimepoint);
     }
     else
     {
         lblValue.Text    = " --- ";
         lblMinValue.Text = " --- ";
         lblMaxValue.Text = " --- ";
         lblMinTime.Text  = " --- ";
         lblMaxTime.Text  = " --- ";
     }
 }
Ejemplo n.º 11
0
        private string GetLineFromDataExt(string line, ref DataObjectExt dobj)
        {
            dobj.DataAvailable = false;
            dobj.Protocol      = DataObjectProtocol.NONE;
            string returnValue = string.Empty;

            if (line.Contains("|"))
            {
                string[] values = line.Split('|');
                //Format: START|humidity|temperature|heatindex|....|EOF
                //This format was defined within the Arduino Sketch
                //  e.g. (random numbers): START|40.30|25.50|26.54|EOF
                // START: Indicates a Start of a data-frame
                //  40.30 --> 40.30% Humidity (relative)
                //  25.50 --> 25.50°C Temperature
                //  26.54 --> 26.54°C Temperature/Heat-Index
                // EOF: End of Frame

                if (values.Length == 7 && values[0].StartsWith("START") && values[6].StartsWith("EOF")) //Protocoll second version
                {
                    dobj.AddDataItem(DataObjectCategory.Humidity.Value, double.Parse(Common.replaceDecPoint(values[2].ToString())), DataObjectCategory.Humidity, Common.SensorValueType.Humidity);
                    dobj.AddDataItem(DataObjectCategory.Temperature.Value, double.Parse(Common.replaceDecPoint(values[3].ToString())), DataObjectCategory.Temperature, Common.SensorValueType.Temperature);
                    dobj.AddDataItem(DataObjectCategory.HeatIndex.Value, double.Parse(Common.replaceDecPoint(values[4].ToString())), DataObjectCategory.HeatIndex, Common.SensorValueType.Temperature);
                    dobj.AddDataItem(DataObjectCategory.AirPressure.Value, double.Parse(Common.replaceDecPoint(values[5].ToString())), DataObjectCategory.AirPressure, Common.SensorValueType.AirPressure);
                    dobj.LastUpdated           = DateTime.Now;
                    dobj.DataAvailable         = true;
                    dobj.AdditionalInformation = "-";
                    dobj.Protocol = DataObjectProtocol.PROTOCOL_TWO;

                    returnValue = "Luftfeuchtigkeit: " + values[2].ToString() + " %\n" +
                                  "Temperatur: " + values[3].ToString() + " °C\n" +
                                  "'Heat Index': " + values[4].ToString() + " °C\n" +
                                  "Luftdruck: " + values[5].ToString() + " mb\n";
                }
                else if (values.Length == 5 && values[0].StartsWith("START") && values[4].StartsWith("EOF")) //Protocol first version
                {
                    dobj.AddDataItem(DataObjectCategory.Humidity.Value, double.Parse(Common.replaceDecPoint(values[1].ToString())), DataObjectCategory.Humidity, Common.SensorValueType.Humidity);
                    dobj.AddDataItem(DataObjectCategory.Temperature.Value, double.Parse(Common.replaceDecPoint(values[2].ToString())), DataObjectCategory.Temperature, Common.SensorValueType.Temperature);
                    dobj.AddDataItem(DataObjectCategory.HeatIndex.Value, double.Parse(Common.replaceDecPoint(values[3].ToString())), DataObjectCategory.HeatIndex, Common.SensorValueType.Temperature);
                    dobj.LastUpdated           = DateTime.Now;
                    dobj.DataAvailable         = true;
                    dobj.AdditionalInformation = "-";
                    dobj.Protocol = DataObjectProtocol.PROTOCOL_ONE;

                    returnValue = "Luftfeuchtigkeit: " + values[1].ToString() + " %\n" +
                                  "Temperatur: " + values[2].ToString() + " °C\n" +
                                  "'Heat Index': " + values[3].ToString() + " °C\n";
                }
                else if (values.Length == 8 && values[0].StartsWith("START") && values[7].StartsWith("EOF")) //Protocol third version
                {
                    dobj.AddDataItem(DataObjectCategory.Humidity.Value, double.Parse(Common.replaceDecPoint(values[2].ToString())), DataObjectCategory.Humidity, Common.SensorValueType.Humidity);
                    dobj.AddDataItem(DataObjectCategory.Temperature.Value, double.Parse(Common.replaceDecPoint(values[3].ToString())), DataObjectCategory.Temperature, Common.SensorValueType.Temperature);
                    dobj.AddDataItem(DataObjectCategory.HeatIndex.Value, double.Parse(Common.replaceDecPoint(values[4].ToString())), DataObjectCategory.HeatIndex, Common.SensorValueType.Temperature);
                    dobj.AddDataItem(DataObjectCategory.AirPressure.Value, double.Parse(Common.replaceDecPoint(values[5].ToString())), DataObjectCategory.AirPressure, Common.SensorValueType.AirPressure);
                    dobj.AddDataItem(DataObjectCategory.LUX.Value, double.Parse(Common.replaceDecPoint(values[6].ToString())), DataObjectCategory.LUX, Common.SensorValueType.LUX);

                    dobj.LastUpdated           = DateTime.Now;
                    dobj.DataAvailable         = true;
                    dobj.AdditionalInformation = "-";
                    dobj.Protocol = DataObjectProtocol.PROTOCOL_THREE;
                    returnValue   = "Luftfeuchtigkeit: " + values[2].ToString() + " %\n" +
                                    "Temperatur: " + values[3].ToString() + " °C\n" +
                                    "'Heat Index': " + values[4].ToString() + " °C\n" +
                                    "Luftdruck: " + values[5].ToString() + " mb\n" +
                                    "LUX: " + values[6].ToString() + " lux\n";
                }
                else
                {
                    dobj.LastUpdated           = DateTime.Now;
                    dobj.DataAvailable         = false;
                    dobj.AdditionalInformation = "-";
                    dobj.Protocol = DataObjectProtocol.NONE;

                    returnValue = "Fehler beim Lesen der Daten";
                }
            }
            else
            {
                dobj.DataAvailable         = false;
                dobj.AdditionalInformation = "-";
                dobj.Protocol = DataObjectProtocol.NONE;

                returnValue = line;
            }

            return(returnValue);
        }