private void PrintSendMsg(byte[] totalbyte) { try { string stmp = ProtoMng.Byte2Hex(totalbyte); string tmpstmp = " >> [" + stmp + "]\r\nSend Message Length >> " + totalbyte.Length + "\r\n"; } catch (Exception ex) { Console.WriteLine("Secession.PrintSendMsg - " + ex.Message); } }
private void RecievedMsg(byte[] rmsg) { try { string smsg = ProtoMng.Byte2Hex(rmsg); this.MainTB.Text += " << [" + smsg + "]\r\nReceive Message Length >> " + rmsg.Length + "\r\n"; this.SetTBScroll(); } catch (Exception ex) { Console.WriteLine("RecvMsgs.RecievedMsg - " + ex.Message); } }
private string LogFileWrite(byte[] totalbyte) { try { string stmp = ProtoMng.Byte2Hex(totalbyte); return(stmp); } catch (Exception ex) { Console.WriteLine("Secession.LogFileWrite - " + ex.Message); return(string.Empty); } }
private void PrintSendMsg(byte[] totalbyte) { try { string stmp = ProtoMng.Byte2Hex(totalbyte); string tmpstmp = " >> [" + stmp + "]\r\nSend Message Length >> " + totalbyte.Length + "\r\n"; if (recvform.Visible) { recvform.MainTextBox += tmpstmp; recvform.SetTBScroll(); } } catch (Exception ex) { Console.WriteLine("WmsgSend.PrintSendMsg - " + ex.Message); } }
void socketClt_tcpConnectedEvt() { try { this.socketClt.ConState = true; String tmpMsg = String.Format("[{0} : 서버에 연결되었습니다]", Properties.Settings.Default.cnfEWSIP); BeginInvoke(new InvokeEWSTCPState(this.ewsTcpstate), true); //로그인 Proto00 p00 = ProtoMng.GetPObject("00") as Proto00; byte[] body = p00.BodyMake(); byte[] totproto = p00.totMake(body); socketClt.tcpClientSndMsg(totproto); this.Invoke(new InvokePrintsendMsg(this.PrintSendMsg), new object[] { totproto }); } catch (Exception ex) { Console.WriteLine("socketClt_tcpConnectedEvt - " + ex.Message); } }
/// <summary> /// 재난 메시지를 판단해 일반, 특수수신기, 저장메시지, 사이렌을 구분해 전송한다. /// </summary> /// <param name="wmessage"></param> public void TcpSendWmsg(WMessage _wmessage) { try { WMessage wmessage = _wmessage; this.PrintSendMsg("TcpSendWmsg 메소드 들어온 직후 - " + DateTime.Now); //logmanager.Dir_Mng(); //#region 로그 etcData 셋팅 //string sopt = string.Empty; //if (wmessage.SOPT_CONTROL) { sopt += "제어 "; } //if (wmessage.SOPT_DMB) { sopt += "일반메시지 "; } //if (wmessage.SOPT_LIVE) { sopt += "라이브 "; } //if (wmessage.SOPT_SMS) { sopt += "SMS "; } //if (wmessage.SOPT_STOREDMESSAGE) { sopt += "저장메시지 "; } //if (wmessage.SOPT_TTS) { sopt += "TTS "; } //if (wmessage.SOPT_WARNING) { sopt += "사이렌 "; } //string etcData = string.Format("메시지ID - {0}, 발령시간 - {1}, 송출이 받은시간 - {2}, 발령구분 - {3}", //wmessage.ID, wmessage.DDateTime, DateTime.Now, sopt); //#endregion if (((wmessage.SOPT_TTS) && (wmessage.SOPT_DMB)) || ((wmessage.SOPT_STOREDMESSAGE) && (wmessage.SOPT_DMB))) { //일반 발령 this.PrintSendMsg("일반 만들기 직전 - " + DateTime.Now.ToString()); Proto02 p02 = ProtoMng.GetPObject("02") as Proto02; byte[] body = p02.BodyMake(wmessage); byte[] totproto = p02.totMake(body); this.PrintSendMsg("일반 만들기 직후 - " + DateTime.Now); soc.tcpClientSndMsg(totproto); this.PrintSendMsg("일반 만들기 후 전송 직후 - " + DateTime.Now); //logmanager.File_Mng(etcData + ", EWS편성으로 전송하는 일반 발령메시지", this.LogFileWrite(totproto)); //특수수신기 발령 this.PrintSendMsg("특수 만들기 직전 - " + DateTime.Now); Proto01 p01 = ProtoMng.GetPObject("01") as Proto01; byte[] devbody = p01.BodyMake(wmessage); byte[] devtotproto = p01.totMake(devbody); this.PrintSendMsg("특수 만들기 직후 - " + DateTime.Now); soc.tcpClientSndMsg(devtotproto); this.PrintSendMsg("특수 만들기 후 전송 직후 - " + DateTime.Now); //logmanager.File_Mng(etcData + ", EWS편성으로 전송하는 특수수신기 발령메시지", this.LogFileWrite(devtotproto)); } else if (wmessage.SOPT_DMB || ((wmessage.SOPT_SMS) && (wmessage.SOPT_DMB)) || ((wmessage.SOPT_WARNING) && (wmessage.SOPT_DMB))) { //일반 발령 this.PrintSendMsg("일반 만들기 직전 - " + DateTime.Now); Proto02 p02 = ProtoMng.GetPObject("02") as Proto02; byte[] body = p02.BodyMake(wmessage); byte[] totproto = p02.totMake(body); this.PrintSendMsg("일반 만들기 직후 - " + DateTime.Now); soc.tcpClientSndMsg(totproto); this.PrintSendMsg("일반 만들기 후 전송 직후 - " + DateTime.Now); //logmanager.File_Mng(etcData + ", EWS편성으로 전송하는 일반 발령메시지", this.LogFileWrite(totproto)); if (wmessage.SOPT_WARNING) { Proto01 p01 = ProtoMng.GetPObject("01") as Proto01; byte[] devbody = p01.BodyMake(wmessage); byte[] devtotproto = p01.totMake(devbody); soc.tcpClientSndMsg(devtotproto); //logmanager.File_Mng(etcData + ", EWS편성으로 전송하는 특수수신기 발령메시지", this.LogFileWrite(devtotproto)); } } else if (wmessage.SOPT_CONTROL || wmessage.SOPT_STOREDMESSAGE || wmessage.SOPT_WARNING || wmessage.SOPT_TTS) { //특수수신기 발령 this.PrintSendMsg("특수 만들기 직전 - " + DateTime.Now); Proto01 p01 = ProtoMng.GetPObject("01") as Proto01; byte[] devbody = p01.BodyMake(wmessage); byte[] devtotproto = p01.totMake(devbody); this.PrintSendMsg("특수 만들기 직후 - " + DateTime.Now); soc.tcpClientSndMsg(devtotproto); this.PrintSendMsg("특수 만들기 후 전송 직후 - " + DateTime.Now); //logmanager.File_Mng(etcData + ", EWS편성으로 전송하는 특수수신기 발령메시지", this.LogFileWrite(devtotproto)); } } catch (Exception ex) { Console.WriteLine("Secession.TcpSendWmsg(WMessage wmessage) - " + ex.Message); } }
private void RecievedMsg(byte[] rmsg) { string smsg = ProtoMng.Byte2Hex(rmsg); recvmng.ParseData(rmsg); }
private void SetSpcMsg(byte[] buff) //UTC 이상하게 뿌리고 있음. { try { if (buff.Length > 50) { byte[] tmp01 = new byte[] { buff[10], buff[9], buff[8], buff[7], 0x00, 0x00, 0x00, 0x00 }; //UTC byte[] tmp02 = new byte[] { buff[42], buff[43], buff[44] }; //재난종류 byte[] tmp03 = new byte[] { buff[14], buff[13], buff[12], buff[11] }; //ID byte[] tmp04 = new byte[] { 0, 0, 0, buff[49], buff[48], buff[47], buff[46], buff[45] }; //복합 5byte byte[] tmp05 = new byte[] { buff[18], buff[17] }; //Body 길이 byte[] tmp07 = new byte[] { buff[20], buff[19] }; //Body안의 길이 // string dtTmpstr = this.deviceres.fnByteToBit(tmp04[7]); dtTmpstr += this.deviceres.fnByteToBit(tmp04[6]); dtTmpstr += this.deviceres.fnByteToBit(tmp04[5]); dtTmpstr += this.deviceres.fnByteToBit(tmp04[4]); dtTmpstr = dtTmpstr.Substring(2, 28); // int IntregionC = this.deviceres.DeviceRegionCount((int)tmp04[3]); //지역수 int Intregion = this.deviceres.DeviceRegion((int)tmp04[3], (int)tmp04[4]); //지역형식 (0=전국, 1=정부지정, 2=행정동, 7=수신기개별) if (Intregion == 7 && IntregionC == 0) { IntregionC = 16; } if (Intregion == 2) { IntregionC++; } long longtmp = BitConverter.ToInt64(tmp04, 0); short shorttmp = BitConverter.ToInt16(tmp05, 0); short bodyinLen = BitConverter.ToInt16(tmp07, 0); byte[] tmp06 = new byte[(IntregionC * 10)]; //지역 for (int i = 0; i < (IntregionC * 10); i++) { tmp06[i] = buff[i + 50]; } string TotalRegion = Encoding.Default.GetString(tmp06); //최종 지역(행정동 코드 또는 수신기번호) string TotalMessage = string.Empty; int tmpline = 50 + (IntregionC * 10); if (buff[tmpline] == 3) { int messageLen = (19 + shorttmp) - (51 + (IntregionC * 10)); byte[] tmp08 = new byte[messageLen]; //단문 for (int i = 0; i < messageLen; i++) { tmp08[i] = buff[i + (51 + (IntregionC * 10))]; } TotalMessage = Encoding.Default.GetString(tmp08); //최종 단문 } else { int messageLen = (19 + shorttmp) - (53 + (IntregionC * 10)); byte[] tmp08 = new byte[messageLen]; //단문 for (int i = 0; i < messageLen; i++) { tmp08[i] = buff[i + (53 + (IntregionC * 10))]; } TotalMessage = Encoding.Default.GetString(tmp08); //최종 단문 } long utc = BitConverter.ToInt64(tmp01, 0); //시간 string dis = Encoding.Default.GetString(tmp02); //재난종류 string sts = "수신성공"; //발령상태 int pkid = BitConverter.ToInt32(tmp03, 0); //PKID ListViewItem lvi = this.set_listview.SetNorListView(utc, dis, sts, TotalMessage, pkid); //리스트뷰에 셋팅 this.listView2.Items.Add(lvi); this.set_listview.SetIndex(this.listView2); this.spcmng = new SpcMng(pkid); this.spcmng.ParseSuccessEvt += new SpcMng.ParseSuccessHandle(spcmng_ParseSuccessEvt); this.spcmng.MuxSuccessEvt += new SpcMng.MuxSuccessHandle(spcmng_MuxSuccessEvt); this.spcmng.EndSuccessEvt += new SpcMng.EndSuccessHandle(spcmng_EndSuccessEvt); BaseP bp = ProtoMng.GetPObject("01", pkid.ToString(), dis, TotalRegion) as Proto01; string db_msg = ProtoMng.MakeFrame(bp); if (Intregion == 0) { datainsert = new DataInsert(); datainsert.InsertAllEvt += new DataInsert.InsertAllHandle(datainsert_InsertAllEvt); datainsert.InsertAreaEvt += new DataInsert.InsertAreaHandle(datainsert_InsertAreaEvt); datainsert.setInit(); datainsert.InsertAll(db_msg, pkid, dis); } else { datainsert = new DataInsert(); datainsert.InsertAllEvt += new DataInsert.InsertAllHandle(datainsert_InsertAllEvt); datainsert.InsertAreaEvt += new DataInsert.InsertAreaHandle(datainsert_InsertAreaEvt); datainsert.setInit(); datainsert.InsertArea(Intregion, IntregionC, TotalRegion, "", pkid, dis); } if (buff.Length > (19 + shorttmp)) { byte[] reTmpbuff = new byte[buff.Length - (19 + shorttmp)]; for (int i = 0; i < buff.Length - (19 + shorttmp); i++) { reTmpbuff[i] = buff[i + (19 + shorttmp)]; } this.parse.ParseData(reTmpbuff); } } } catch (Exception ex) { Console.WriteLine("MainForm.SetSpcMsg - " + ex.Message); } }
/// <summary> /// 임시로 만든 WMessage로 TCP로 송신한다. /// </summary> /// <param name="wmessage"></param> private void TcpSendWmsg(WMessage wmessage) { try { if (wmessage.SendPart != WMessage.E_sendPart.SMS) { SocketClient soc = SocketClient.getInstance(); if (((wmessage.SOPT_TTS) && (wmessage.SOPT_DMB))) { //일반 발령 Proto02 p02 = ProtoMng.GetPObject("02") as Proto02; byte[] body = p02.BodyMake(wmessage); byte[] totproto = p02.totMake(body); soc.tcpClientSndMsg(totproto); if (this.recvform.InvokeRequired) { this.Invoke(new InvokeSetTextByte(this.PrintSendMsg), new object[] { totproto }); } else { this.PrintSendMsg(totproto); } //특수수신기 발령 Proto01 p01 = ProtoMng.GetPObject("01") as Proto01; byte[] devbody = p01.BodyMake(wmessage); byte[] devtotproto = p01.totMake(devbody); soc.tcpClientSndMsg(devtotproto); if (this.recvform.InvokeRequired) { this.Invoke(new InvokeSetTextByte(this.PrintSendMsg), new object[] { devtotproto }); } else { this.PrintSendMsg(devtotproto); } } else if (wmessage.SOPT_DMB) { //일반 발령 Proto02 p02 = ProtoMng.GetPObject("02") as Proto02; byte[] body = p02.BodyMake(wmessage); byte[] totproto = p02.totMake(body); soc.tcpClientSndMsg(totproto); if (this.recvform.InvokeRequired) { this.Invoke(new InvokeSetTextByte(this.PrintSendMsg), new object[] { totproto }); } else { this.PrintSendMsg(totproto); } } else if (wmessage.SOPT_CONTROL || wmessage.SOPT_STOREDMESSAGE || wmessage.SOPT_WARNING || wmessage.SOPT_TTS) { //특수수신기 발령 Proto01 p01 = ProtoMng.GetPObject("01") as Proto01; byte[] devbody = p01.BodyMake(wmessage); byte[] devtotproto = p01.totMake(devbody); soc.tcpClientSndMsg(devtotproto); if (this.recvform.InvokeRequired) { this.Invoke(new InvokeSetTextByte(this.PrintSendMsg), new object[] { devtotproto }); } else { this.PrintSendMsg(devtotproto); } } } } catch (Exception ex) { Console.WriteLine("TcpSendWmsg - " + ex.Message); } }