internal bool SendPacket(DataPacket p, DateTime time) { string s = p.ToString(); this.DoLog(Agent.ScadaDataClient, string.Format("[{0}]-->: {1}", DateTime.Now, s)); return(this.Send(Encoding.ASCII.GetBytes(s))); }
internal bool SendDataPacket(DataPacket p) { if (p == null) { return(false); } if (this.SendDataStarted || this.Type == Type.Country) { string s = p.ToString(); return(this.Send(Encoding.ASCII.GetBytes(s))); } return(false); }
// '大流量' 数据 private void SendFlowDataPackets(string deviceKey, Dictionary <string, object> data) { DataPacket p = builder.GetFlowDataPacket(deviceKey, data, true); if (this.agent != null) { if (this.agent.SendDataPacket(p)) { string msg = string.Format("RD: {0}", p.ToString()); Log.GetLogFile(deviceKey).Log(msg); this.UpdateSendDataRecord(deviceKey, false); } } if (this.countryCenterAgent != null && this.countryCenterAgent.Stream != null) { if (this.countryCenterAgent.SendDataPacket(p)) { string msg = string.Format("RD: {0}", p.ToString()); Log.GetLogFile(deviceKey).Log(msg); this.UpdateSendDataRecord(deviceKey, false); } } }
internal bool SendHistoryDataPacket(DataPacket p) { if (p == null) { return(false); } bool result = false; string s = p.ToString(); result = this.Send(Encoding.ASCII.GetBytes(s)); if (result) { if (this.NotifyEvent != null && !string.IsNullOrEmpty(p.DeviceKey)) { this.NotifyEvent(this, NotifyEvents.HistoryDataSent, p.DeviceKey, s); } } return(result); }
/// <summary> /// /// </summary> /// <param name="time"></param> /// <param name="deviceKey"></param> private void SendNonFileDataPackets(DateTime time, string deviceKey) { this.data.Clear(); string errorMessage = string.Empty; var r = DBDataSource.GetData(this.MySqlCommand, deviceKey, time, default(DateTime), null, null, this.data, out errorMessage); if (r == ReadResult.ReadOK) { if (this.data.Count > 0) { DataPacket p = null; if (Case(deviceKey, "Scada.MDS") || Case(deviceKey, "Scada.AIS")) { this.SendFlowDataPackets(deviceKey, this.data[0]); } else if (Case(deviceKey, "scada.shelter")) { this.SendShelterDataPackets(deviceKey, this.data[0]); } else { // 其他数据 if (deviceKey == "scada.hpic" && this.InHpicException) { this.InHpicException = false; DataPacket packet = this.builder.GetExceptionNotifyPacket(deviceKey, false); this.agent.SendExceptionNotify(packet); } p = builder.GetDataPacket(deviceKey, this.data[0], true); if (this.agent.SendDataPacket(p)) { string msg = string.Format("RD: {0}", p.ToString()); Log.GetLogFile(deviceKey).Log(msg); this.UpdateSendDataRecord(deviceKey, false); } if (this.countryCenterAgent != null && this.agent.SendDataDirectlyStarted) { this.countryCenterAgent.SendDataPacket(p); } } } else { string line = string.Format("RD Error: count={0} [{1}: {2}]", this.data.Count, deviceKey, time); Log.GetLogFile(deviceKey).Log(line); } } else { // 发送异常通知 if (r == ReadResult.NoDataFound && deviceKey == "scada.hpic") { if (!this.InHpicException) { this.InHpicException = true; DataPacket packet = this.builder.GetExceptionNotifyPacket(deviceKey, true); this.agent.SendExceptionNotify(packet); } } string line = string.Format("RD Error: {0} - {1} [{2}: {3}]", r.ToString(), errorMessage, deviceKey, time); Log.GetLogFile(deviceKey).Log(line); } }
internal void SendReplyPacket(DataPacket p, DateTime time) { string s = p.ToString(); this.Send(Encoding.ASCII.GetBytes(s)); }
internal void SendDataPacket(DataPacket p, DateTime time) { if (p == null) return; // Only start or history. if (this.SendDataStarted || this.OnHistoryData) { string s = p.ToString(); this.Send(Encoding.ASCII.GetBytes(s)); } }
internal bool SendReplyPacket(DataPacket p, DateTime time) { string s = p.ToString(); return(this.Send(Encoding.ASCII.GetBytes(s))); }
internal bool SendHistoryDataPacket(DataPacket p) { if (p == null) return false; bool result = false; string s = p.ToString(); result = this.Send(Encoding.ASCII.GetBytes(s)); if (result) { if (this.NotifyEvent != null && !string.IsNullOrEmpty(p.DeviceKey)) { this.NotifyEvent(this, NotifyEvents.HistoryDataSent, p.DeviceKey, s); } } return result; }
internal bool SendDataPacket(DataPacket p) { if (p == null) return false; if (this.SendDataStarted) { string s = p.ToString(); return this.Send(Encoding.ASCII.GetBytes(s)); } return false; }
internal bool SendPacket(DataPacket p, DateTime time) { string s = p.ToString(); // TODO:! this.DoLog(Agent.ScadaDataClient, string.Format("-->: {0}", s)); return this.Send(Encoding.ASCII.GetBytes(s)); }