private void GasLogger(XmlNodeList rankList) { string DateTimefetch; foreach (XmlNode myRankNode in rankList) { int CC = 0; for (int i = 0; i < myRankNode.ChildNodes.Count; i++) { DataList = new ArrayList(); if (myRankNode.ChildNodes[i].Name == "pt") { addr = 0; //grpData.Text = "Writing to " + addr + " register"; //if (count != 0) { addr = count * 10; } else { count = 0; addr = count; } DateTimefetch = myRankNode.ChildNodes[i].InnerText; string chk = DateTimefetch[0].ToString(); if (chk == "1") { string text; unit = "1"; year = DateTimefetch.Substring(29, 4); month = DateTimefetch.Substring(34, 2); day = DateTimefetch.Substring(37, 2); hr = DateTimefetch.Substring(40, 2); mins = DateTimefetch.Substring(43, 2); secs = DateTimefetch.Substring(46, 2); if (DateTimefetch.Length == 49) { text = DateTimefetch.Substring(48, 1); } else { text = DateTimefetch.Substring(48, DateTimefetch.Length - 48); } if (text.Length > 4) { text = text.Substring(0, 4); } decimal dec = Convert.ToDecimal(text) * 100; dec = Math.Round(dec, 2); value = System.Math.Abs((Convert.ToInt32(dec))).ToString(); DataList.Add(unit); DataList.Add(year); DataList.Add(month); DataList.Add(day); DataList.Add(hr); DataList.Add(mins); DataList.Add(secs); DataList.Add(value); string C1 = DateTimefetch.Substring(29, 10); DateTime tod = Convert.ToDateTime(C1); string C2 = tod.ToString("dd/M/yy", CultureInfo.InvariantCulture); Yr1 = year; month1 = month; day1 = day; hr1 = hr; mins1 = mins; OUT1 = value; CC++; } else if (chk == "2") { string text; unit = "2"; year = DateTimefetch.Substring(29, 4); month = DateTimefetch.Substring(34, 2); day = DateTimefetch.Substring(37, 2); hr = DateTimefetch.Substring(40, 2); mins = DateTimefetch.Substring(43, 2); secs = DateTimefetch.Substring(46, 2); if (DateTimefetch.Length == 49) { text = DateTimefetch.Substring(48, 1); } else { text = DateTimefetch.Substring(48, DateTimefetch.Length - 48); } if (text.Length > 4) { text = text.Substring(0, 4); } decimal dec = Convert.ToDecimal(text) * 100; dec = Math.Round(dec, 2); value = System.Math.Abs((Convert.ToInt32(dec))).ToString(); DataList.Add(unit); DataList.Add(year); DataList.Add(month); DataList.Add(day); DataList.Add(hr); DataList.Add(mins); DataList.Add(secs); DataList.Add(value); string C1 = DateTimefetch.Substring(29, 10); DateTime tod = Convert.ToDateTime(C1); string C2 = tod.ToString("dd/M/yy", CultureInfo.InvariantCulture); Yr1 = year; month1 = month; day1 = day; hr1 = hr; mins1 = mins; OUT2 = value; CC++; } else if (chk == "3") { string text; unit = "3"; year = DateTimefetch.Substring(28, 4); month = DateTimefetch.Substring(33, 2); day = DateTimefetch.Substring(36, 2); hr = DateTimefetch.Substring(39, 2); mins = DateTimefetch.Substring(42, 2); secs = DateTimefetch.Substring(45, 2); if (DateTimefetch.Length == 48) { text = DateTimefetch.Substring(47, 1); } else { text = DateTimefetch.Substring(47, DateTimefetch.Length - 48); } if (text.Length > 4) { text = text.Substring(0, 4); } decimal dec = Convert.ToDecimal(text) * 100; dec = Math.Round(dec, 2); value = System.Math.Abs((Convert.ToInt32(dec))).ToString(); DataList.Add(unit); DataList.Add(year); DataList.Add(month); DataList.Add(day); DataList.Add(hr); DataList.Add(mins); DataList.Add(secs); DataList.Add(value); string C1 = DateTimefetch.Substring(28, 10); DateTime tod = Convert.ToDateTime(C1); string C2 = tod.ToString("dd/M/yy", CultureInfo.InvariantCulture); IN1 = value; CC++; } else if (chk == "4") { string text; unit = "4"; year = DateTimefetch.Substring(21, 4); month = DateTimefetch.Substring(26, 2); day = DateTimefetch.Substring(29, 2); hr = DateTimefetch.Substring(32, 2); mins = DateTimefetch.Substring(35, 2); secs = DateTimefetch.Substring(38, 2); if (DateTimefetch.Length == 40) { text = DateTimefetch.Substring(40, 1); } else { text = DateTimefetch.Substring(40, DateTimefetch.Length - 40); } if (text.Length > 4) { text = text.Substring(0, 4); } decimal dec = Convert.ToDecimal(text) * 100; dec = Math.Round(dec, 2); value = System.Math.Abs((Convert.ToInt32(dec))).ToString(); DataList.Add(unit); DataList.Add(year); DataList.Add(month); DataList.Add(day); DataList.Add(hr); DataList.Add(mins); DataList.Add(secs); DataList.Add(value); string C1 = DateTimefetch.Substring(21, 10); DateTime tod = Convert.ToDateTime(C1); string C2 = tod.ToString("dd/M/yy", CultureInfo.InvariantCulture); TEMP = value; CC++; } if (CC == 4) { transmit(); } } } } }
private void WaterLogger(XmlNodeList rankList) { string DateTimefetch; foreach (XmlNode myRankNode in rankList) { for (int i = 0; i < myRankNode.ChildNodes.Count; i++) { DataList = new ArrayList(); if (myRankNode.ChildNodes[i].Name == "pt") { Int32 addr = 0; if (count != 0) { addr = count * 10; } else { count = 0; addr = count; } DateTimefetch = myRankNode.ChildNodes[i].InnerText; string chk = DateTimefetch[0].ToString(); if (chk == "1") { string text; unit = "1"; year = DateTimefetch.Substring(16, 4); month = DateTimefetch.Substring(21, 2); day = DateTimefetch.Substring(24, 2); hr = DateTimefetch.Substring(27, 2); mins = DateTimefetch.Substring(30, 2); secs = DateTimefetch.Substring(33, 2); if (DateTimefetch.Length == 35) { text = DateTimefetch.Substring(35, 1); } else { text = DateTimefetch.Substring(35, DateTimefetch.Length - 35); } decimal dec = Convert.ToDecimal(text) * 100; dec = Math.Round(dec, 2); value = (Convert.ToInt32(dec)).ToString(); DataList.Add(unit); DataList.Add(year); DataList.Add(month); DataList.Add(day); DataList.Add(hr); DataList.Add(mins); DataList.Add(secs); DataList.Add(value); } else if (chk == "2") { string text; unit = "2"; year = DateTimefetch.Substring(10, 4); month = DateTimefetch.Substring(15, 2); day = DateTimefetch.Substring(18, 2); hr = DateTimefetch.Substring(21, 2); mins = DateTimefetch.Substring(24, 2); secs = DateTimefetch.Substring(27, 2); if (DateTimefetch.Length == 29) { text = DateTimefetch.Substring(29, 1); } else { text = DateTimefetch.Substring(29, DateTimefetch.Length - 29); } decimal dec = Convert.ToDecimal(text) * 100; dec = Math.Round(dec, 2); value = (Convert.ToInt32(dec)).ToString(); DataList.Add(unit); DataList.Add(year); DataList.Add(month); DataList.Add(day); DataList.Add(hr); DataList.Add(mins); DataList.Add(secs); DataList.Add(value); } Yr1 = year; month1 = month; day1 = day; hr1 = hr; mins1 = mins; } } } }