public bool Parse_SD(String rawMsg, string id, out CSDStruct sd) { sd = new CSDStruct(); sd.StationID = id; sd.Cmd = rawMsg; try { //创建返回的数据对象 var datas = new List <CTimeAndAllData>(); string msg = rawMsg.Substring(rawMsg.IndexOf("BEG") + 3, rawMsg.IndexOf("END")); msg = msg.Replace("\\r\\n", "|"); msg = msg.Replace("\r\n", "|"); var datasegs = msg.Split('|'); foreach (string d in datasegs) { if (d.Contains("VT")) { CTimeAndAllData data = new CTimeAndAllData(); try { string timeStr = d.Substring(0, d.IndexOf("Z:")); string waterStr = d.Substring(d.IndexOf("Z:") + 2, d.IndexOf("PT:") - d.IndexOf("Z:") - 2); string rainStr = d.Substring(d.IndexOf("PT:") + 3, d.IndexOf("VT:") - d.IndexOf("PT:") - 2); string voltageStr = d.Substring(d.IndexOf("VT:") + 3); data.Time = Convert.ToDateTime(timeStr); data.water = waterStr; data.rain = rainStr; data.voltage = voltageStr; } catch (Exception e) { System.Diagnostics.Debug.WriteLine("数据:" + rawMsg); System.Diagnostics.Debug.WriteLine("数据解析出错:" + e.Message); } datas.Add(data); } } sd.Datas = datas; return(true); } catch (Exception exp) { System.Diagnostics.Debug.WriteLine("数据:" + rawMsg); System.Diagnostics.Debug.WriteLine("批量数据解析不完整" + exp.Message); } return(false); }
public bool Parse_SD(string msg, string id, out CSDStruct sd) { throw new NotImplementedException(); }
private bool ParseData(string msg, string gprs, uint modemId) { // InvokeMessage("协议。。。 ", "进入函数7"); try { string rawData = msg; string sid; try { sid = Manager.XmlStationData.Instance.GetStationByGprsID(gprs); } catch (Exception e) { Debug.WriteLine("查找站点id失败,赋值为9999" + e.ToString()); sid = "9999"; } if (msg.Contains("$")) { string data = string.Empty; if (!ProtocolHelpers.DeleteSpecialChar(msg, out data)) { return(false); } msg = data; CReportStruct report = new CReportStruct(); CDownConf downReport = new CDownConf(); string protocol = Manager.XmlStationData.Instance.GetProtocolBySId(sid); if (protocol == "YNXY") { Up = new Data.YNXY.UpParser(); Down = new Data.YNXY.DownParser(); } else if (protocol == "ZYJBX") { Up = new Data.ZYJBX.UpParser(); Down = new Data.ZYJBX.DownParser(); } #region 1K //批量传输解析 if (msg.Contains("1K")) { var station = FindStationBySID(sid); if (station == null) { throw new Exception("批量传输,站点匹配错误"); } CBatchStruct batch = new CBatchStruct(); InvokeMessage(String.Format("{0,-10} ", "批量传输") + msg, "接收"); if (Down.Parse_Flash(msg, EChannelType.GPRS, out batch)) { if (this.BatchDataReceived != null) { this.BatchDataReceived.Invoke(null, new BatchEventArgs() { Value = batch, RawData = msg }); } } } #endregion #region 1G if (msg.Contains("1G")) { //if (msg.Contains("RG")) //{ // var lists = msg.Split('$'); // foreach (var segMsg in lists) // { // if (segMsg.Length < 5) // { // continue; // } // string plusMsg = "$" + segMsg; // string rtype = "人工报"; // InvokeMessage("gprs号码: " + gprs + " " + String.Format("{0,-10} ", rtype) + plusMsg, "接收"); // string package = Up.Parse_1(plusMsg, out report); // if (package != "") // { // report.ChannelType = EChannelType.GPRS; // report.ListenPort = this.GetListenPort().ToString(); // report.flagId = gprs; // SendTru(modemId, package); // //TODO 重新定义事件 // if (this.UpDataReceived != null) // { // this.UpDataReceived.Invoke(null, new UpEventArgs() { Value = report, RawData = plusMsg }); // } // } // else // { // InvokeMessage(" " + rawData, "接收"); // } // } //} //else if (msg.Contains("1G21") || msg.Contains("1G22") || msg.Contains("1G25")) // 定时报,加报 { if (msg.Contains("1G29")) { var station = FindStationBySID(sid); if (station == null) { throw new Exception("批量传输,站点匹配错误"); } CBatchStruct batch = new CBatchStruct(); InvokeMessage(String.Format("{0,-10} ", "批量传输") + msg, "接收"); if (Down.Parse_Batch(msg, out batch)) { if (this.BatchDataReceived != null) { this.BatchDataReceived.Invoke(null, new BatchEventArgs() { Value = batch, RawData = msg }); } } } else { var lists = msg.Split('$'); foreach (var segMsg in lists) { if (segMsg.Length < 5) { continue; } string plusMsg = "$" + segMsg; if (Up.Parse(plusMsg, out report)) { report.ChannelType = EChannelType.GPRS; report.ListenPort = this.GetListenPort().ToString(); report.flagId = gprs; string rtype = report.ReportType == EMessageType.EAdditional ? "加报" : "定时报"; InvokeMessage("gprs号码: " + gprs + " " + String.Format("{0,-10} ", rtype) + plusMsg, "接收"); //TODO 重新定义事件 if (this.UpDataReceived != null) { this.UpDataReceived.Invoke(null, new UpEventArgs() { Value = report, RawData = plusMsg }); } } else { InvokeMessage(" " + rawData, "接收"); } } } } else { Down.Parse(rawData, out downReport); if (downReport != null) { InvokeMessage(String.Format("{0,-10} ", "下行指令读取参数") + rawData, "接收"); if (this.DownDataReceived != null) { this.DownDataReceived.Invoke(null, new DownEventArgs() { Value = downReport, RawData = rawData }); } } } #endregion } } else if (msg.Contains("BEG")) { CSDStruct sd = new CSDStruct(); if (Down.Parse_SD(msg, sid, out sd)) { InvokeMessage(String.Format("{0,-10} ", "批量SD传输") + msg, "接收"); if (this.BatchSDDataReceived != null) { this.BatchSDDataReceived.Invoke(null, new BatchSDEventArgs() { Value = sd, RawData = msg }); } } } else if (msg.Contains("#")) { CEntitySoilData soil = new CEntitySoilData(); CReportStruct soilReport = new CReportStruct(); if (Soil.Parse(rawData, out soil, out soilReport)) { soil.ChannelType = EChannelType.GPRS; if (null != this.SoilDataReceived) { this.SoilDataReceived(null, new CEventSingleArgs <CEntitySoilData>(soil)); } if (null != soilReport && null != this.UpDataReceived) { soilReport.ChannelType = EChannelType.GPRS; soilReport.ListenPort = this.GetListenPort().ToString(); this.UpDataReceived(null, new UpEventArgs() { RawData = rawData, Value = soilReport }); } } } else { return(false); } return(true); } catch (Exception exp) { System.Diagnostics.Debug.WriteLine("GPRS 数据解析出错 !" + msg + "\r\n" + exp.Message); } return(false); }
public bool Parse_SD(String rawMsg, string id, out CSDStruct sd) { sd = null; return(false); }
private void DealData() { while (true) { m_semaphoreData.WaitOne(); //阻塞当前线程,知道被其它线程唤醒 // 获取对data内存缓存的访问权 m_mutexListDatas.WaitOne(); List <HDModemDataStruct> dataListTmp = m_listDatas; m_listDatas = new List <HDModemDataStruct>(); //开辟一快新的缓存区 m_mutexListDatas.ReleaseMutex(); for (int i = 0; i < dataListTmp.Count; ++i) { try { HDModemDataStruct dat = dataListTmp[i]; string data = System.Text.Encoding.Default.GetString(dat.m_data_buf); string temp = data.Trim(); string result = null; if (temp.Contains("TRU")) { Debug.WriteLine("接收数据TRU完成,停止计时器"); //m_timer.Stop(); InvokeMessage("TRU " + System.Text.Encoding.Default.GetString(dat.m_modemId), "接收"); if (this.ErrorReceived != null) { this.ErrorReceived.Invoke(null, new ReceiveErrorEventArgs() { // Msg = "TRU " + dat.m_modemId Msg = "TRU " + System.Text.Encoding.Default.GetString(dat.m_modemId) }); } } if (temp.Contains("ATE0")) { Debug.WriteLine("接收数据ATE0完成,停止计时器"); //m_timer.Stop(); // InvokeMessage("ATE0", "接收"); if (this.ErrorReceived != null) { this.ErrorReceived.Invoke(null, new ReceiveErrorEventArgs() { Msg = "ATE0" }); } } if (temp.Contains("$")) { result = temp.Substring(temp.IndexOf("$"), temp.IndexOf("\0")); string sid = result.Substring(1, 4); string type = result.Substring(5, 2); //if (sid == "\0\0\0\0") //{ // continue; //} ////批量传输解析 //if (type == "1K") //{ // var station = FindStationBySID(sid); // if (station == null) // throw new Exception("批量传输,站点匹配错误"); // CBatchStruct batch = new CBatchStruct(); // if (Down.Parse_Flash(result, out batch)) // { // InvokeMessage(String.Format("{0,-10} ", "批量传输") + temp, "接收"); // if (this.BatchDataReceived != null) // this.BatchDataReceived.Invoke(null, new BatchEventArgs() { Value = batch, RawData = temp }); // } // if (Down.Parse_Batch(result, out batch)) // { // InvokeMessage(String.Format("{0,-10} ", "批量传输") + temp, "接收"); // if (this.BatchDataReceived != null) // this.BatchDataReceived.Invoke(null, new BatchEventArgs() { Value = batch, RawData = temp }); // } //} String dataProtocol = null; if (HdProtocolMap.ContainsKey("HD-GPRS")) { dataProtocol = HdProtocolMap["HD-GPRS"]; } switch (dataProtocol) { //case "LN": // break; //case "SXDZ": // { // CReportStruct report = new CReportStruct(); // CDownConf downReport = new CDownConf(); // Data.SXDZ.UpParser Up1 = new Data.SXDZ.UpParser(); // Data.SXDZ.DownParser down1 = new Data.SXDZ.DownParser(); // //批量传输解析 // if (type == "1K") // { // var station = FindStationBySID(sid); // if (station == null) // throw new Exception("批量传输,站点匹配错误"); // CBatchStruct batch = new CBatchStruct(); // if (down1.Parse_Flash(result, out batch)) // { // InvokeMessage(String.Format("{0,-10} ", "批量传输") + temp, "接收"); // if (this.BatchDataReceived != null) // this.BatchDataReceived.Invoke(null, new BatchEventArgs() { Value = batch, RawData = temp }); // } // //if (down1.Parse_Batch(result, out batch)) // //{ // // InvokeMessage(String.Format("{0,-10} ", "批量传输") + temp, "接收"); // // if (this.BatchDataReceived != null) // // this.BatchDataReceived.Invoke(null, new BatchEventArgs() { Value = batch, RawData = temp }); // //} // } // Up1.Parse(result, out report); // down1.Parse(result, out downReport); // if (report != null) // { // report.ChannelType = EChannelType.GPRS; // report.ListenPort = this.GetListenPort().ToString(); // InvokeMessage(String.Format("{0,-10} ", "") + result, "接收"); // //TODO 重新定义事件 // if (this.UpDataReceived != null) // { // this.UpDataReceived.Invoke(null, new UpEventArgs() { Value = report, RawData = result }); // } // } // if (downReport != null) // { // InvokeMessage(String.Format("{0,-10} ", "下行指令读取参数") + result, "接收"); // if (this.DownDataReceived != null) // this.DownDataReceived.Invoke(null, new DownEventArgs() { Value = downReport, RawData = result }); // } // break; // } //case "HJJBX": // //需要处理新老协议 // //TODO 判断新老协议 // bool isNew = false; // if (isNew) // { // List<CUpReport> reports = new List<CUpReport>(); // Up = new Protocol.Data.HJJBX.UpParser(); // Up.Parse_New(result, out reports); // foreach(var report2 in reports) // { // report2.ChannelType = EChannelType.GPRS; // report2.ListenPort = this.GetListenPort().ToString(); // } // InvokeMessage(String.Format("{0,-10} ","") + result, "接收"); // //TODO 重新定义事件 // if (this.UpDataReceived_new != null) // { // this.UpDataReceived_new.Invoke(null, new UpEventArgs_new() { Value = reports, RawData = result }); // } // } // else // { // List<CUpReport> reports = new List<CUpReport>(); // Up = new Protocol.Data.HJJBX.UpParser(); // Up.Parse_Old(result, out reports); // foreach (var report1 in reports) // { // report1.ChannelType = EChannelType.GPRS; // report1.ListenPort = this.GetListenPort().ToString(); // } // InvokeMessage(String.Format("{0,-10} ", "") + result, "接收"); // //测试代码 // Dictionary<string, HDModemInfoStruct> data11 = new Dictionary<string, HDModemInfoStruct>(); // this.getDTUList(out data11); // //TODO 重新定义事件 // if (this.UpDataReceived_new != null) // { // this.UpDataReceived_new.Invoke(null, new UpEventArgs_new() { Value = reports, RawData = result }); // } // } // break; case "ZYJBX": { CReportStruct report = new CReportStruct(); CDownConf downReport = new CDownConf(); Data.ZYJBX.UpParser Up1 = new Data.ZYJBX.UpParser(); Data.ZYJBX.DownParser down1 = new Data.ZYJBX.DownParser(); //批量传输解析 if (type == "1K") { var station = FindStationBySID(sid); if (station == null) { throw new Exception("批量传输,站点匹配错误"); } CBatchStruct batch = new CBatchStruct(); InvokeMessage(String.Format("{0,-10} ", "批量传输") + temp, "接收"); if (down1.Parse_Flash(result, EChannelType.GPRS, out batch)) { if (this.BatchDataReceived != null) { this.BatchDataReceived.Invoke(null, new BatchEventArgs() { Value = batch, RawData = temp }); } } else if (down1.Parse_Batch(result, out batch)) { if (this.BatchDataReceived != null) { this.BatchDataReceived.Invoke(null, new BatchEventArgs() { Value = batch, RawData = temp }); } } } if (result.Contains("1G21") || result.Contains("1G22") || result.Contains("1G25")) { var lists = result.Split('$'); foreach (var msg in lists) { if (msg.Length < 5) { continue; } string plusMsg = "$" + msg; Up1.Parse(plusMsg, out report); if (report != null) { string gprs = System.Text.Encoding.Default.GetString(dat.m_modemId); gprs = gprs.Contains("\0")? gprs.Replace("\0", "") : gprs; report.ChannelType = EChannelType.GPRS; report.ListenPort = this.GetListenPort().ToString(); report.flagId = gprs; string rtype = report.ReportType == EMessageType.EAdditional ? "加报" : "定时报"; InvokeMessage("gprs号码: " + gprs + " " + String.Format("{0,-10} ", rtype) + plusMsg, "接收"); //TODO 重新定义事件 if (this.UpDataReceived != null) { this.UpDataReceived.Invoke(null, new UpEventArgs() { Value = report, RawData = plusMsg }); } InvokeMessage("TRU " + gprs, "发送"); byte[] bts = new byte[] { 84, 82, 85, 13, 10 }; this.sendHex(gprs.Trim(), bts, (uint)bts.Length, null); } } } else { down1.Parse(result, out downReport); if (downReport != null) { InvokeMessage(String.Format("{0,-10} ", "下行指令读取参数") + result, "接收"); if (this.DownDataReceived != null) { this.DownDataReceived.Invoke(null, new DownEventArgs() { Value = downReport, RawData = result }); } } } break; } //case "XYJBX": // { // CReportStruct report = new CReportStruct(); // CDownConf downReport = new CDownConf(); // Data.XYJBX.UpParser Up1 = new Data.XYJBX.UpParser(); // Data.XYJBX.DownParser down1 = new Data.XYJBX.DownParser(); // //批量传输解析 // if (type == "1K") // { // var station = FindStationBySID(sid); // if (station == null) // throw new Exception("批量传输,站点匹配错误"); // CBatchStruct batch = new CBatchStruct(); // //if (down1.Parse_Flash(result, out batch)) // //{ // // InvokeMessage(String.Format("{0,-10} ", "批量传输") + temp, "接收"); // // if (this.BatchDataReceived != null) // // this.BatchDataReceived.Invoke(null, new BatchEventArgs() { Value = batch, RawData = temp }); // //} // //if (down1.Parse_Batch(result, out batch)) // //{ // // InvokeMessage(String.Format("{0,-10} ", "批量传输") + temp, "接收"); // // if (this.BatchDataReceived != null) // // this.BatchDataReceived.Invoke(null, new BatchEventArgs() { Value = batch, RawData = temp }); // //} // } // Up1.Parse(result, out report); // down1.Parse(result, out downReport); // if (report != null) // { // report.ChannelType = EChannelType.GPRS; // report.ListenPort = this.GetListenPort().ToString(); // InvokeMessage(String.Format("{0,-10} ", "") + result, "接收"); // //TODO 重新定义事件 // if (this.UpDataReceived != null) // { // this.UpDataReceived.Invoke(null, new UpEventArgs() { Value = report, RawData = result }); // } // } // if (downReport != null) // { // InvokeMessage(String.Format("{0,-10} ", "下行指令读取参数") + result, "接收"); // if (this.DownDataReceived != null) // this.DownDataReceived.Invoke(null, new DownEventArgs() { Value = downReport, RawData = result }); // } // break; // } default: break; } } //List<CUpReport> reports = new List<CUpReport>(); //Up = new UpParser(); //Up.Parse_New(result, out reports); //获取DTU列表的函数,DTU在线列表测试 //uint amount = this.getDTUAmount(); //HDModemInfoStruct data1= new HDModemInfoStruct(); //this.getDTUByPosition(0, out data1); //Dictionary<string, HDModemInfoStruct> datas = new Dictionary<string, HDModemInfoStruct>(); //this.getDTUList(out datas); if (temp.Contains("BEG")) { Data.ZYJBX.DownParser down1 = new Data.ZYJBX.DownParser(); CSDStruct sd = new CSDStruct(); string gprs = System.Text.Encoding.Default.GetString(dat.m_modemId); gprs = gprs.Replace("\0", ""); //string gprs = dat.m_modemId.ToString(); string id = Manager.XmlStationDataSerializer.Instance.GetStationByGprsID(gprs); if (down1.Parse_SD(temp, id, out sd)) { InvokeMessage(String.Format("{0,-10} ", "批量SD传输") + temp, "接收"); if (this.BatchSDDataReceived != null) { this.BatchSDDataReceived.Invoke(null, new BatchSDEventArgs() { Value = sd, RawData = temp }); } } } } catch (Exception e) { Debug.WriteLine("" + e.Message); } } } }
private void DealData() { while (true) { m_semaphoreData.WaitOne(); //阻塞当前线程,知道被其它线程唤醒 // 获取对data内存缓存的访问权 m_mutexListDatas.WaitOne(); List <HDModemDataStruct> dataListTmp = m_listDatas; m_listDatas = new List <HDModemDataStruct>(); //开辟一快新的缓存区 m_mutexListDatas.ReleaseMutex(); for (int i = 0; i < dataListTmp.Count; ++i) { try { HDModemDataStruct dat = dataListTmp[i]; string data = System.Text.Encoding.Default.GetString(dat.m_data_buf).TrimEnd('\0'); string recvData = data.Trim(); InvokeMessage(data, "原始数据"); string temp = data.Trim(); string gprs = System.Text.Encoding.Default.GetString(dat.m_modemId); gprs = gprs.Replace("\0", ""); string sid = Manager.XmlStationData.Instance.GetStationByGprsID(gprs); string result = null; if (temp.Contains("TRU")) { Debug.WriteLine("接收数据TRU完成,停止计时器"); //m_timer.Stop(); InvokeMessage("TRU " + System.Text.Encoding.Default.GetString(dat.m_modemId), "接收"); if (this.ErrorReceived != null) { this.ErrorReceived.Invoke(null, new ReceiveErrorEventArgs() { // Msg = "TRU " + dat.m_modemId Msg = "TRU " + System.Text.Encoding.Default.GetString(dat.m_modemId) }); } } if (temp.Contains("ATE0")) { Debug.WriteLine("接收数据ATE0完成,停止计时器"); //m_timer.Stop(); // InvokeMessage("ATE0", "接收"); if (this.ErrorReceived != null) { this.ErrorReceived.Invoke(null, new ReceiveErrorEventArgs() { Msg = "ATE0" }); } } if (temp.Contains("$")) { result = temp.Substring(temp.IndexOf("$")); int length = int.Parse(result.Substring(11, 4)); //获取报文长度 if (length > MAX_BUFFER) { continue; } result = result.Substring(0, length); if (!(result.StartsWith("$") && result.EndsWith("\r\n"))) { InvokeMessage(result + "报文开始符结束符不合法", "接收"); } String dataProtocol = Manager.XmlStationData.Instance.GetProtocolBySId(sid); CReportStruct report = new CReportStruct(); CDownConf downReport = new CDownConf(); if (dataProtocol == "RG30") { Up = new Data.RG30.UpParser(); Down = new Data.RG30.DownParser(); } if (dataProtocol == "SM100H") { Up = new Data.SM100H.UpParser(); Down = new Data.SM100H.DownParser(); } //时差法 if (dataProtocol == "TDXY") { Up = new Data.TDXY.UpParser(); Down = new Data.TDXY.DownParser(); } //中游局协议 if (dataProtocol == "ZYJBX") { Up = new Data.ZYJBX.UpParser(); Down = new Data.ZYJBX.DownParser(); } //蒸发协议 if (dataProtocol == "ZFXY") { Up = new Data.ZFXY.UpParse(); Down = new Data.ZFXY.DownParse(); } if (dataProtocol == "EN2B") { Up = new Data.EN2B.UpParser(); Down = new Data.EN2B.DownParser(); } if (dataProtocol == "OBS") { Up = new Protocol.Data.OBS.UpParser(); Down = new Protocol.Data.OBS.DownParser(); } //云南协议 if (dataProtocol == "YNXY") { Up = new Data.YNXY.UpParser(); Down = new Data.YNXY.DownParser(); } //批量传输解析 if (temp.Contains("1K")) { var station = FindStationBySID(sid); if (station == null) { throw new Exception("批量传输,站点匹配错误"); } CBatchStruct batch = new CBatchStruct(); InvokeMessage(String.Format("{0,-10} ", "批量传输") + temp, "接收"); if (Down.Parse_Flash(result, EChannelType.GPRS, out batch)) { if (this.BatchDataReceived != null) { this.BatchDataReceived.Invoke(null, new BatchEventArgs() { Value = batch, RawData = temp }); } } else if (Down.Parse_Batch(result, out batch)) { if (this.BatchDataReceived != null) { this.BatchDataReceived.Invoke(null, new BatchEventArgs() { Value = batch, RawData = temp }); } } } //+ 代表的是蒸发报文,需要特殊处理 //数据报文解析 if (result.Contains("1G21") || result.Contains("1G22") || result.Contains("1G23") || result.Contains("1G25") || result.Contains("1G29") || result.Contains("+")) { //回复TRU InvokeMessage("TRU " + gprs, "发送"); byte[] bts = new byte[] { 84, 82, 85, 13, 10 }; this.sendHex(gprs.Trim(), bts, (uint)bts.Length, null); //根据$将字符串进行分割 var lists = result.Split('$'); foreach (var msg in lists) { if (msg.Length < 10) { continue; } string plusMsg = "$" + msg.TrimEnd(); bool ret = Up.Parse(plusMsg, out report); if (ret && report != null) { report.ChannelType = EChannelType.GPRS; report.ListenPort = this.GetListenPort().ToString(); report.flagId = gprs; string rtype = report.ReportType == EMessageType.EAdditional ? "加报" : "定时报"; InvokeMessage("gprs号码: " + gprs + " " + String.Format("{0,-10} ", rtype) + plusMsg, "接收"); //TODO 重新定义事件 if (this.UpDataReceived != null) { this.UpDataReceived.Invoke(null, new UpEventArgs() { Value = report, RawData = plusMsg }); } } } } //其他报文 else { Down.Parse(result, out downReport); if (downReport != null) { InvokeMessage(String.Format("{0,-10} ", "下行指令读取参数") + result, "接收"); if (this.DownDataReceived != null) { this.DownDataReceived.Invoke(null, new DownEventArgs() { Value = downReport, RawData = result }); } } } } if (temp.Contains("BEG")) { Data.ZYJBX.DownParser down1 = new Data.ZYJBX.DownParser(); CSDStruct sd = new CSDStruct(); string id = Manager.XmlStationData.Instance.GetStationByGprsID(gprs); if (down1.Parse_SD(temp, id, out sd)) { InvokeMessage(String.Format("{0,-10} ", "批量SD传输") + temp, "接收"); if (this.BatchSDDataReceived != null) { this.BatchSDDataReceived.Invoke(null, new BatchSDEventArgs() { Value = sd, RawData = temp }); } } } } catch (Exception e) { Debug.WriteLine("" + e.Message); } } } }