Esempio n. 1
0
        private void ProcessThread(string rawData, Business.Arrays.SensorData resultTable)
        {
            // Se verifica que el mensaje sea para SDA.
            if (rawData.StartsWith("SDA: ")) rawData = rawData.Remove(0, 5);
            else return;

            // Se separan los datos
            string[] rawColumnsData = rawData.Split(' ');

            Business.Arrays.GenericArray<Business.Measurement> receivedData = new Business.Arrays.GenericArray<Business.Measurement>();
            Business.MeasureUnit measureInfo;
            Business.Measurement newMeasure;

            // Se convierten los datos a double
            for (int i = 0; i < rawColumnsData.Length; ++i)
            {
                try
                {
                    double processedData = Convert.ToDouble(rawColumnsData[i]);

                    measureInfo = new Business.MeasureUnit(resultTable.Columns[i].Measure, resultTable.Columns[i].Unit);
                    newMeasure = new Business.Measurement(measureInfo);

                    newMeasure.Value = processedData;
                    receivedData.Add(newMeasure);
                }
                catch (Exception ex) { RuntimeLogs.SendLog(ex.Message, "Processing.Process(string, ref Business.Arrays.SensorData )"); }
            }

            resultTable.AddRow(receivedData);
        }
Esempio n. 2
0
        public DataTable MeasureUnitListToDataTable(Business.Arrays.MeasureUnitArray data)
        {
            DataTable result = new DataTable();

            result.Columns.Add("Measure", typeof(string));
            result.Columns.Add("Unit", typeof(string));

            for (int i = 0; i < data.List.Size; ++i)
            {
                Business.MeasureUnit measure = data.List[i];
                DataRow newRow = result.NewRow();

                newRow[0] = measure.Measure.Name;
                newRow[1] = measure.Unit.Name;

                result.Rows.Add(newRow);
            }
            return(result);
        }