public override SurveyResult Ping() { try { var req = new Request17(NetworkAddress); var resp = new Response17(SendMessageToDevice(req)); if (resp == null) { return new SurveyResult { State = SurveyResultState.NoResponse } } ; OnSendMessage(resp.Version); return(new SurveyResult { State = SurveyResultState.Success }); } catch (Exception ex) { OnSendMessage(string.Format("ошибка: {0}", ex.Message)); } return(new SurveyResult { State = SurveyResultState.NotRecognized }); }
public override SurveyResultData ReadCurrentValues() { var data = new List <Data>(); try { OnSendMessage(string.Format("чтение мгновенных данных")); var dateResponse = new ResponseDateTime(SendMessageToDevice(new Request4(NetworkAddress, 0x8000, 2))); Response4 current = null; current = ReadCurrent(0xC6AC); if (current != null) { data.Add(new Data("Eтс(0)", MeasuringUnitType.Gkal_h, dateResponse.Date, current.Values.ElementAt(0))); } current = ReadCurrent(0xC6AE); if (current != null) { data.Add(new Data("Eгв(0)", MeasuringUnitType.Gkal_h, dateResponse.Date, current.Values.ElementAt(0))); } current = ReadCurrent(0xC6B0); if (current != null) { data.Add(new Data("Gтс(0)", MeasuringUnitType.tonn_h, dateResponse.Date, current.Values.ElementAt(0))); } current = ReadCurrent(0xC6B2); if (current != null) { data.Add(new Data("Eтс(1)", MeasuringUnitType.Gkal_h, dateResponse.Date, current.Values.ElementAt(0))); } current = ReadCurrent(0xC6B4); if (current != null) { data.Add(new Data("Eгв(1)", MeasuringUnitType.Gkal_h, dateResponse.Date, current.Values.ElementAt(0))); } current = ReadCurrent(0xC6B6); if (current != null) { data.Add(new Data("Gтс(1)", MeasuringUnitType.tonn_h, dateResponse.Date, current.Values.ElementAt(0))); } current = ReadCurrent(0xC6B8); if (current != null) { data.Add(new Data("Eтс(2)", MeasuringUnitType.Gkal_h, dateResponse.Date, current.Values.ElementAt(0))); } current = ReadCurrent(0xC6BA); if (current != null) { data.Add(new Data("Eгв(2)", MeasuringUnitType.Gkal_h, dateResponse.Date, current.Values.ElementAt(0))); } current = ReadCurrent(0xC6BC); if (current != null) { data.Add(new Data("Gтс(2)", MeasuringUnitType.tonn_h, dateResponse.Date, current.Values.ElementAt(0))); } current = ReadCurrent(0xC048); if (current != null) { data.Add(new Data("t(0)", MeasuringUnitType.C, dateResponse.Date, current.Values.ElementAt(0))); } current = ReadCurrent(0xC04A); if (current != null) { data.Add(new Data("t(1)", MeasuringUnitType.C, dateResponse.Date, current.Values.ElementAt(0))); } current = ReadCurrent(0xC04C); if (current != null) { data.Add(new Data("t(2)", MeasuringUnitType.C, dateResponse.Date, current.Values.ElementAt(0))); } current = ReadCurrent(0xC04E); if (current != null) { data.Add(new Data("t(3)", MeasuringUnitType.C, dateResponse.Date, current.Values.ElementAt(0))); } current = ReadCurrent(0xC050); if (current != null) { data.Add(new Data("t(4)", MeasuringUnitType.C, dateResponse.Date, current.Values.ElementAt(0))); } current = ReadCurrent(0xC052); if (current != null) { data.Add(new Data("t(5)", MeasuringUnitType.C, dateResponse.Date, current.Values.ElementAt(0))); } current = ReadCurrent(0xC054); if (current != null) { data.Add(new Data("t(6)", MeasuringUnitType.C, dateResponse.Date, current.Values.ElementAt(0))); } current = ReadCurrent(0xC056); if (current != null) { data.Add(new Data("t(7)", MeasuringUnitType.C, dateResponse.Date, current.Values.ElementAt(0))); } current = ReadCurrent(0xC058); if (current != null) { data.Add(new Data("t(8)", MeasuringUnitType.C, dateResponse.Date, current.Values.ElementAt(0))); } current = ReadCurrent(0xC05A); if (current != null) { data.Add(new Data("Q(0)", MeasuringUnitType.m3_h, dateResponse.Date, current.Values.ElementAt(0))); } current = ReadCurrent(0xC05C); if (current != null) { data.Add(new Data("Q(1)", MeasuringUnitType.m3_h, dateResponse.Date, current.Values.ElementAt(0))); } current = ReadCurrent(0xC05E); if (current != null) { data.Add(new Data("Q(2)", MeasuringUnitType.m3_h, dateResponse.Date, current.Values.ElementAt(0))); } current = ReadCurrent(0xC060); if (current != null) { data.Add(new Data("Q(3)", MeasuringUnitType.m3_h, dateResponse.Date, current.Values.ElementAt(0))); } current = ReadCurrent(0xC062); if (current != null) { data.Add(new Data("Q(4)", MeasuringUnitType.m3_h, dateResponse.Date, current.Values.ElementAt(0))); } current = ReadCurrent(0xC064); if (current != null) { data.Add(new Data("Q(5)", MeasuringUnitType.m3_h, dateResponse.Date, current.Values.ElementAt(0))); } current = ReadCurrent(0xC066); if (current != null) { data.Add(new Data("Q(6)", MeasuringUnitType.m3_h, dateResponse.Date, current.Values.ElementAt(0))); } current = ReadCurrent(0xC068); if (current != null) { data.Add(new Data("Q(7)", MeasuringUnitType.m3_h, dateResponse.Date, current.Values.ElementAt(0))); } current = ReadCurrent(0xC06A); if (current != null) { data.Add(new Data("Q(8)", MeasuringUnitType.m3_h, dateResponse.Date, current.Values.ElementAt(0))); } current = ReadCurrent(0xC03C); if (current != null) { data.Add(new Data("P(0)", MeasuringUnitType.MPa, dateResponse.Date, current.Values.ElementAt(0))); } current = ReadCurrent(0xC03E); if (current != null) { data.Add(new Data("P(1)", MeasuringUnitType.MPa, dateResponse.Date, current.Values.ElementAt(0))); } current = ReadCurrent(0xC040); if (current != null) { data.Add(new Data("P(2)", MeasuringUnitType.MPa, dateResponse.Date, current.Values.ElementAt(0))); } current = ReadCurrent(0xC042); if (current != null) { data.Add(new Data("P(3)", MeasuringUnitType.MPa, dateResponse.Date, current.Values.ElementAt(0))); } current = ReadCurrent(0xC044); if (current != null) { data.Add(new Data("P(4)", MeasuringUnitType.MPa, dateResponse.Date, current.Values.ElementAt(0))); } current = ReadCurrent(0xC046); if (current != null) { data.Add(new Data("P(5)", MeasuringUnitType.MPa, dateResponse.Date, current.Values.ElementAt(0))); } current = ReadCurrent(0xC0C6); if (current != null) { data.Add(new Data("Mтс(1)", MeasuringUnitType.tonn, dateResponse.Date, current.Values.ElementAt(0))); } //current = ReadCurrent(0xC0CE); //if (current != null) OnSendMessage(string.Format("Параметр {0}={1}", "Mтс(1) сервис", current.Values.ElementAt(0))); //current = ReadCurrent(0xC0DE); //if (current != null) OnSendMessage(string.Format("Параметр {0}={1}", "Mтс(2)", current.Values.ElementAt(0))); //current = ReadCurrent(0xC0E6); //if (current != null) OnSendMessage(string.Format("Параметр {0}={1}", "Mтс(2) сервис", current.Values.ElementAt(0))); current = ReadCurrent(0xC238, true); if (current != null) { data.Add(new Data("MтрТР1ТС1", MeasuringUnitType.tonn, dateResponse.Date, current.Values.ElementAt(0))); } //current = ReadCurrent(0xC242); //if (current != null) OnSendMessage(string.Format("Параметр {0}={1}", "Mтр1(1) сервис", current.Values.ElementAt(0))); current = ReadCurrent(0xC274, true); if (current != null) { data.Add(new Data("MтрТР2ТС1", MeasuringUnitType.tonn, dateResponse.Date, current.Values.ElementAt(0))); } //current = ReadCurrent(0xC27E); //if (current != null) OnSendMessage(string.Format("Параметр {0}={1}", "Mтр2(1) сервис", current.Values.ElementAt(0))); current = ReadCurrent(0xC328, true);//, "Mтр1(2)", MeasuringUnitType.tonn, 1, CalculationType.Average, dateResponse.Date); if (current != null) { data.Add(new Data("MтрТР1ТС2", MeasuringUnitType.tonn, dateResponse.Date, current.Values.ElementAt(0))); } //current = ReadCurrent(0xC332, "Mтр1(2) сервис", MeasuringUnitType.tonn, 1, CalculationType.Average, dateResponse.Date); //if (current != null) OnSendMessage(string.Format("Параметр {0}={1}", current.ParameterName, current.Value)); current = ReadCurrent(0xC364, true); if (current != null) { data.Add(new Data("MтрТР2ТС2", MeasuringUnitType.tonn, dateResponse.Date, current.Values.ElementAt(0))); } //current = ReadCurrent(0xC36E, "Mтр2(2) сервис", MeasuringUnitType.tonn, 1, CalculationType.Average, dateResponse.Date); ////if (current != null) OnSendMessage(string.Format("Параметр {0}={1}", current.ParameterName, current.Value)); current = ReadCurrent(0xC418, true); if (current != null) { data.Add(new Data("MтрТР1ТС3", MeasuringUnitType.tonn, dateResponse.Date, current.Values.ElementAt(0))); } current = ReadCurrent(0xC454, true); if (current != null) { data.Add(new Data("MтрТР2ТС3", MeasuringUnitType.tonn, dateResponse.Date, current.Values.ElementAt(0))); } current = ReadCurrent(0xC234, true); if (current != null) { data.Add(new Data("WтрТР1ТС1", MeasuringUnitType.Gkal, dateResponse.Date, current.Values.ElementAt(0))); } //current = ReadCurrent(0xC240); //if (current != null) OnSendMessage(string.Format("Параметр {0}={1}", "Wтр1(1) сервис", current.Values.ElementAt(0))); current = ReadCurrent(0xC270, true); if (current != null) { data.Add(new Data("WтрТР2ТС1", MeasuringUnitType.Gkal, dateResponse.Date, current.Values.ElementAt(0))); } ////if (current != null) OnSendMessage(string.Format("Параметр {0}={1}", current.ParameterName, current.Value)); //current = ReadCurrent(0xC27C, "Wтр2(1) сервис", MeasuringUnitType.tonn, 1, CalculationType.Average, dateResponse.Date); ////if (current != null) OnSendMessage(string.Format("Параметр {0}={1}", current.ParameterName, current.Value)); current = ReadCurrent(0xC324, true); if (current != null) { data.Add(new Data("WтрТР1ТС2", MeasuringUnitType.Gkal, dateResponse.Date, current.Values.ElementAt(0))); } //current = ReadCurrent(0xC330, "Wтр1(2) сервис", MeasuringUnitType.tonn, 1, CalculationType.Average, dateResponse.Date); ////if (current != null) OnSendMessage(string.Format("Параметр {0}={1}", current.ParameterName, current.Value)); current = ReadCurrent(0xC360, true); if (current != null) { data.Add(new Data("WтрТР2ТС2", MeasuringUnitType.Gkal, dateResponse.Date, current.Values.ElementAt(0))); } //current = ReadCurrent(0xC36C, "Wтр2(2) сервис", MeasuringUnitType.tonn, 1, CalculationType.Average, dateResponse.Date); ////if (current != null) OnSendMessage(string.Format("Параметр {0}={1}", current.ParameterName, current.Value)); current = ReadCurrent(0xC420, true); if (current != null) { data.Add(new Data("WтрТР1ТС3", MeasuringUnitType.Gkal, dateResponse.Date, current.Values.ElementAt(0))); } current = ReadCurrent(0xC450, true); if (current != null) { data.Add(new Data("WтрТР2ТС3", MeasuringUnitType.Gkal, dateResponse.Date, current.Values.ElementAt(0))); } //Чистое время работы ТС в штатном режиме, ч current = ReadCurrent(0x8016); if (current != null) { data.Add(new Data("ТнарТС1", MeasuringUnitType.h, dateResponse.Date, current.Values.ElementAt(0) / 3600)); } current = ReadCurrent(0x8024); if (current != null) { data.Add(new Data("ТнарТС2", MeasuringUnitType.h, dateResponse.Date, current.Values.ElementAt(0) / 3600)); } current = ReadCurrent(0x8032); if (current != null) { data.Add(new Data("ТнарТС3", MeasuringUnitType.h, dateResponse.Date, current.Values.ElementAt(0) / 3600)); } //Чтение заводского номера //OnSendMessage(string.Format("Чтение заводского номера " )); current = ReadConstant(0x8002); if (current != null) { OnSendMessage(string.Format("Serial Number={0}", current.Values.ElementAt(0))); } if (current != null) { data.Add(new Data("SN", MeasuringUnitType.Unknown, dateResponse.Date, current.Values.ElementAt(0))); } //Чтение версии ПО var req = new Request17(NetworkAddress); var resp = new Response17(SendMessageToDevice(req)); string version = resp.Version.Replace(".", "").Replace("VZLJOT ", ""); //string[] tmp = version.Split('.'); OnSendMessage(string.Format("version=" + version)); double v = Convert.ToDouble(version); //double w = Convert.ToDouble(v); OnSendMessage(string.Format("resp ? null")); if (resp != null) { OnSendMessage(string.Format("Version={0}", v)); OnSendMessage(string.Format("resp != null")); data.Add(new Data("Version", MeasuringUnitType.Unknown, dateResponse.Date, v)); } //var date = dateResponse.Date.AddDays(-1).Date; //OnSendMessage(string.Format("чтение итоговых часовых данных за {0:dd.MM.yyyy HH:mm}", date)); //var bytes = SendMessageToDevice(new Request65ByDate(NetworkAddress, date, ArchiveType.DailyGrowing)); //var dataResponse = new Response65Totals(bytes); ////Response65.Channel = channel.Key; ////var dataResponse = SendMessageToDevice<Response65>(new Request65ByDate(NetworkAddress, date, channel.Value)); ////foreach (var d in dataResponse.Data) ////{ //// //убираем лишние 59:59 //// d.Date = d.Date.AddMinutes(-59).AddSeconds(-59); //// data.Add(d); ////} //OnSendMessage(dataResponse.Text); } catch (Exception ex) { var iex = ex; var message = ""; do { message += "->" + iex.Message; iex = iex.InnerException; }while (iex != null); OnSendMessage(string.Format("ошибка: {0}", message)); } return(new SurveyResultData { Records = data, State = SurveyResultState.Success }); }