Пример #1
0
        P1Data ParseData(StringBuilder sb)
        {
            var data = new P1Data();

            data.LogMoment = DateTime.Now;

            var values = GetValuesFromMessage(sbMessage.Replace("(m3)\r\n", "").Replace("\r\n", "#").Replace("*kWh", "").Replace("*kW", "").Replace(")(", "@").ToString());

            data.E1            = Double.Parse(((string[])values["1-0:1.8.1"])[0]);
            data.E2            = Double.Parse(((string[])values["1-0:1.8.2"])[0]);
            data.E1Retour      = Double.Parse(((string[])values["1-0:2.8.1"])[0]);
            data.E2Retour      = Double.Parse(((string[])values["1-0:2.8.2"])[0]);
            data.CurrentUsage  = Double.Parse(((string[])values["1-0:1.7.0"])[0]);
            data.CurrentRetour = Double.Parse(((string[])values["1-0:2.7.0"])[0]);
            data.CurrentTariff = Double.Parse(((string[])values["0-0:96.14.0"])[0]);
            if (values.Contains("0-1:24.3.0"))
            {
                data.LastGasTransmit = ((string[])values["0-1:24.3.0"])[0];
                data.Gas             = Double.Parse(((string[])values["0-1:24.3.0"])[5]);
            }
            return(data);
        }
Пример #2
0
        private static void WriteToSdCard(P1Data p1Data)
        {
            string path    = @"\SD\" + DateTime.Now.ToString("yyyyMM");
            string logFile = path + @"\" + DateTime.Now.ToString("yyyyMMdd") + ".log";

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            if (!File.Exists(logFile))
            {
                using (var sw = new StreamWriter(logFile, true))
                {
                    sw.WriteLine("Timestamp;E1;E2;E1Retour;E2Retour;CurrentTariff;CurrentUsage;CurrentRetour;GasMeasurementMoment;GasMeasurementValue;PvProductionCounter");
                }
            }

            using (var sw = new StreamWriter(logFile, true))
            {
                var logLine = new StringBuilder(512);
                logLine.Append(p1Data.LogMoment.ToString("yyyy-MM-ddTHH:mm:ss") + ";");
                logLine.Append(p1Data.E1.ToString() + ";");
                logLine.Append(p1Data.E2.ToString() + ";");
                logLine.Append(p1Data.E1Retour.ToString() + ";");
                logLine.Append(p1Data.E2Retour.ToString() + ";");
                logLine.Append(p1Data.CurrentTariff.ToString() + ";");
                logLine.Append(p1Data.CurrentUsage.ToString() + ";");
                logLine.Append(p1Data.CurrentRetour.ToString() + ";");
                logLine.Append(p1Data.LastGasTransmit + ";");
                logLine.Append(p1Data.Gas.ToString() + ";");
                logLine.Append(s0Counter.ToString());

                sw.WriteLine(logLine.ToString());
            }
        }
Пример #3
0
        private static void WriteToSdCard(P1Data p1Data)
        {
            string path = @"\SD\" + DateTime.Now.ToString("yyyyMM");
            string logFile = path + @"\" + DateTime.Now.ToString("yyyyMMdd") + ".log";

            if (!Directory.Exists(path)) {
                Directory.CreateDirectory(path);
            }

            if (!File.Exists(logFile)) {
                using (var sw = new StreamWriter(logFile, true)) {
                    sw.WriteLine("Timestamp;E1;E2;E1Retour;E2Retour;CurrentTariff;CurrentUsage;CurrentRetour;GasMeasurementMoment;GasMeasurementValue;PvProductionCounter");
                }
            }

            using (var sw = new StreamWriter(logFile, true)) {
                var logLine = new StringBuilder(512);
                logLine.Append(p1Data.LogMoment.ToString("yyyy-MM-ddTHH:mm:ss") + ";");
                logLine.Append(p1Data.E1.ToString() + ";");
                logLine.Append(p1Data.E2.ToString() + ";");
                logLine.Append(p1Data.E1Retour.ToString() + ";");
                logLine.Append(p1Data.E2Retour.ToString() + ";");
                logLine.Append(p1Data.CurrentTariff.ToString() + ";");
                logLine.Append(p1Data.CurrentUsage.ToString() + ";");
                logLine.Append(p1Data.CurrentRetour.ToString() + ";");
                logLine.Append(p1Data.LastGasTransmit + ";");
                logLine.Append(p1Data.Gas.ToString() + ";");
                logLine.Append(s0Counter.ToString());

                sw.WriteLine(logLine.ToString());
            }
        }
        P1Data ParseData(StringBuilder sb)
        {
            var data = new P1Data();
            data.LogMoment = DateTime.Now;

            var values = GetValuesFromMessage(sbMessage.Replace("(m3)\r\n", "").Replace("\r\n", "#").Replace("*kWh", "").Replace("*kW", "").Replace(")(", "@").ToString());

            data.E1 = Double.Parse(((string[])values["1-0:1.8.1"])[0]);
            data.E2 = Double.Parse(((string[])values["1-0:1.8.2"])[0]);
            data.E1Retour = Double.Parse(((string[])values["1-0:2.8.1"])[0]);
            data.E2Retour = Double.Parse(((string[])values["1-0:2.8.2"])[0]);
            data.CurrentUsage = Double.Parse(((string[])values["1-0:1.7.0"])[0]);
            data.CurrentRetour = Double.Parse(((string[])values["1-0:2.7.0"])[0]);
            data.CurrentTariff = Double.Parse(((string[])values["0-0:96.14.0"])[0]);
            if (values.Contains("0-1:24.3.0")) {
                data.LastGasTransmit = ((string[])values["0-1:24.3.0"])[0];
                data.Gas = Double.Parse(((string[])values["0-1:24.3.0"])[5]);
            }
            return data;
        }