public bool ExternelServerStart() { try { DelegateState.InvokeDispatchStateEvent("正在初始化外围服务..."); string FILEPATH = Application.StartupPath + @"/sysconfig.xml"; Hashtable htServer = XMLClass.GetXMLByParentNode(FILEPATH, XMLConstClass.NODE_SERVER); string port = "2018"; string maxclient = "200"; string rcvtimeout = "100"; string sendtimeout = "100"; string buffersize = "128"; if (htServer.Contains(XMLConstClass.PORT)) { port = htServer[XMLConstClass.PORT].ToString(); } if (htServer.Contains(XMLConstClass.MAXCONNECTCOUNT)) { maxclient = htServer[XMLConstClass.MAXCONNECTCOUNT].ToString(); } if (htServer.Contains(XMLConstClass.RECTIMEOUT)) { rcvtimeout = htServer[XMLConstClass.RECTIMEOUT].ToString(); } if (htServer.Contains(XMLConstClass.SENDTIMEOUT)) { sendtimeout = htServer[XMLConstClass.SENDTIMEOUT].ToString(); } if (htServer.Contains(XMLConstClass.BUFFERSIZE)) { buffersize = htServer[XMLConstClass.BUFFERSIZE].ToString(); } IServerConfig nannyclient_serverconfig = new SocketServer.ServerConfig() { Port = Convert.ToInt16(port), MaxClientCount = Convert.ToInt16(maxclient), RecOutTime = Convert.ToInt16(rcvtimeout), ReceiveBufferSize = Convert.ToInt16(buffersize), SendBufferSize = Convert.ToInt16(buffersize) }; if (_server == null) { _server = new TCPServer(); _server.ReceiveMes += _server_ReceiveMes; } if (!_server.Setup(nannyclient_serverconfig)) { return(false); } else { if (!_server.Start()) { return(false); } } return(true); } catch (Exception ex) { DelegateState.InvokeDispatchStateEvent(ex.Message); return(false); } }
/// <summary> /// 启动 /// </summary> public virtual bool Start() { try { IPAddress ip = IPAddress.Parse(ComPara.ServerIP); IPEndPoint ipep = new IPEndPoint(ip, ComPara.Port);//IP和端口 Tcpsocket.Bind(new IPEndPoint(IPAddress.Parse(CoreData.SysParameter["LocalIP"]), 0)); Tcpsocket.Connect(new IPEndPoint(ip, ComPara.Port)); CurrToken = Guid.NewGuid().ToString(); Communication(CurrToken); LastRecTime = DateTime.Now; return(true); } catch (Exception ex) { CarBaseStateInfo car = new CarBaseStateInfo(); car.AgvID = this.DeviceID; car.bIsCommBreak = true; DelegateState.InvokeCarFeedbackEvent(car); return(false); } finally { communicationobserve_timer.Enabled = true; } }
public void Start() { Task.Run(() => { try { //while (true) //{ // OperateResult opr = melsecMc.ConnectServer(); // if (!opr.IsSuccess) // { // DelegateState.InvokeDispatchStateEvent("呼叫器:" + this.PLCCode.ToString() + "IP:" + melsecMc.IpAddress + "连接失败! 将重新尝试连接..."); // Thread.Sleep(60 * 1000); // //return false; // } // else // { // break; // } //} melsecMc.SetPersistentConnection(); DelegateState.InvokeDispatchStateEvent("呼叫器:" + this.PLCCode.ToString() + "IP:" + melsecMc.IpAddress + "连接成功!"); processor = new Thread(Polling); processor.IsBackground = true; processor.Start(); } catch (Exception ex) { DelegateState.InvokeDispatchStateEvent(ex.Message); } }); }
/// <summary> /// 通讯状态观察 /// </summary> private void CommunicationObser(object sender, System.Timers.ElapsedEventArgs e) { try { communicationobserve_timer.Enabled = false; //先判断小车是否已经掉线 if (LastRecLong > 2) { //如果接受消息时间已经大于2秒,则认为车子掉线了。 DelegateState.InvokeDispatchStateEvent(this.DeviceID.ToString() + "车,已经掉线,将在1秒后重新尝试连接..."); //通知调度程序 小车已经掉线 CarBaseStateInfo car = new CarBaseStateInfo(); car.bIsCommBreak = true; car.AgvID = this.DeviceID; DelegateState.InvokeCarFeedbackEvent(car); if (LastConnectLong > 3) { //如果车子掉线且连接时间超过3秒则需要重连 LogHelper.WriteLog("重连小车" + DeviceID.ToString()); ReConnect(); } } } catch (Exception ex) { DelegateState.InvokeDispatchStateEvent(this.DeviceID.ToString() + "车,观察线程异常"); LogHelper.WriteErrorLog(ex); } finally { { communicationobserve_timer.Enabled = true; } } }
/// <summary> /// 重新尝试连接小车 /// </summary> public void ReConnect() { try { if (Init()) { if (ReStart()) { LastConnectTime = DateTime.Now; } else { ChargeStationInfo io = new ChargeStationInfo(); io.ID = this.DeviceID; io.IsCommBreak = true; DelegateState.InvokeChargeChangeEvent(io); } } else { ChargeStationInfo io = new ChargeStationInfo(); io.ID = this.DeviceID; io.IsCommBreak = true; DelegateState.InvokeChargeChangeEvent(io); } } catch (Exception ex) { ChargeStationInfo io = new ChargeStationInfo(); io.ID = this.DeviceID; io.IsCommBreak = true; DelegateState.InvokeChargeChangeEvent(io); } }
/// <summary> /// 通讯状态观察 /// </summary> private void CommunicationObser(object sender, System.Timers.ElapsedEventArgs e) { try { communicationobserve_timer.Enabled = false; //接收超时,进行重新连接 if (LastConnectLong > 3) { LogHelper.WriteLog("重连" + DeviceID.ToString() + "号IO设备"); ReConnect(); } if (LastRecLong > 2) { IODeviceInfo IOInfo = new IODeviceInfo(); IOInfo.ID = this.DeviceID; DelegateState.InvokeDispatchStateEvent(this.DeviceID.ToString() + "号IO设备掉线,重新尝试连接..."); //通知调度程序 小车已经掉线 IOInfo.bIsCommBreak = true; DelegateState.InvokeIOFeedBackEvent(IOInfo); } } catch (Exception ex) { DelegateState.InvokeDispatchStateEvent(this.DeviceID.ToString() + "号IO设备,观察线程异常"); LogHelper.WriteErrorLog(ex); } finally { if (!IsStop) { communicationobserve_timer.Enabled = true; } } }
/// <summary> /// 启动 /// </summary> /// <returns></returns> public bool Start() { try { //先执行ping 命令 KeepServer = true; IPAddress ip = IPAddress.Parse(ComPara.ServerIP); IPEndPoint ipep = new IPEndPoint(ip, ComPara.Port);//IP和端口 //Tcpsocket.Connect(new IPEndPoint(ip, ComPara.Port)); ConnectSocketDelegate connect = ConnectSocket; IAsyncResult asyncResult = connect.BeginInvoke(ipep, Tcpsocket, null, null); bool connectSuccess = asyncResult.AsyncWaitHandle.WaitOne(3 * 1000, false); if (!connectSuccess) { //MessageBox.Show(string.Format("失败!错误信息:{0}", "连接超时")); return(false); } bool exmessage = connect.EndInvoke(asyncResult); if (exmessage == false) { return(false); } //if (!string.IsNullOrEmpty(exmessage)) //{ // //MessageBox.Show(string.Format("失败!错误信息:{0}", exmessage)); // return false; //} LastRecTime = DateTime.Now; processor = new Thread(Communication); processor.IsBackground = true; processor.Start(); RecevProvessor = new Thread(ReceverMes); RecevProvessor.IsBackground = true; RecevProvessor.Start(); return(true); } catch (Exception ex) { KeepServer = false; IODeviceInfo IOInfo = new IODeviceInfo(); IOInfo.ID = this.DeviceID; IOInfo.bIsCommBreak = true; DelegateState.InvokeIOFeedBackEvent(IOInfo); return(false); } finally { this.communicationobserve_timer.Enabled = true; } }
/// <summary> /// 启动 /// </summary> public bool Start() { try { IPAddress ip = IPAddress.Parse(ComPara.ServerIP); IPEndPoint ipep = new IPEndPoint(ip, ComPara.Port);//IP和端口 Tcpsocket.Connect(new IPEndPoint(ip, ComPara.Port)); processor = new Thread(Communication); processor.IsBackground = true; processor.Start(); //IPAddress ip = IPAddress.Parse(ComPara.ServerIP); //IPEndPoint ipep = new IPEndPoint(ip, ComPara.Port);//IP和端口 ////Tcpsocket.Connect(new IPEndPoint(ip, ComPara.Port)); //ConnectSocketDelegate connect = ConnectSocket; //IAsyncResult asyncResult = connect.BeginInvoke(ipep, Tcpsocket, null, null); //bool connectSuccess = asyncResult.AsyncWaitHandle.WaitOne(3 * 1000, false); //if (!connectSuccess) //{ // //MessageBox.Show(string.Format("失败!错误信息:{0}", "连接超时")); // return false; //} //bool result = connect.EndInvoke(asyncResult); //if (!result) //{ return false; } //LastRecTime = DateTime.Now; //processor = new Thread(Communication); //processor.IsBackground = true; //processor.Start(); return(true); } catch (Exception ex) { ChargeStationInfo io = new ChargeStationInfo(); io.ID = this.DeviceID; io.IsCommBreak = true; DelegateState.InvokeChargeChangeEvent(io); return(false); } finally { communicationobserve_timer.Enabled = true; } }
//Change state manager public void ChangeState(DelegateState newState) { if (currentState != null) { currentState.active = false; currentState.Exit?.Invoke(); } if (newState != null) { newState.active = true; newState.Enter?.Invoke(); currentState = newState; } }
public void Execute_Its_Delegates_On_Corresponding_Methods() { bool executedEnter = false; bool executedUpdate = false; bool executedExit = false; var delegateState = new DelegateState( () => executedEnter = true, () => executedUpdate = true, () => executedExit = true); delegateState.Enter(); delegateState.Update(); delegateState.Exit(); Assert.That(executedEnter && executedUpdate && executedExit, "All methods have been executed"); }
public bool InitSiemens() { try { melsecMc = new SiemensS7Net(SiemensPLCS.S1200) { IpAddress = this.ConnParam.ServerIP, Port = this.ConnParam.Port }; return(true); } catch (Exception ex) { DelegateState.InvokeDispatchStateEvent(ex.Message); return(false); } }
/// <summary> /// 重新创建连接 /// </summary> public void ReConnect() { try { //LastConnectTime = DateTime.Now; if (Init()) { CarBaseStateInfo car = new CarBaseStateInfo(); car.AgvID = this.DeviceID; LastConnectTime = DateTime.Now; ReStart(); } } catch (Exception ex) { DelegateState.InvokeDispatchStateEvent("尝试连接" + this.DeviceID.ToString() + "车异常,将在3秒后重新尝试连接..."); } }
/// <summary> /// 通讯观察线程 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void CommunicationObser(object sender, System.Timers.ElapsedEventArgs e) { try { communicationobserve_timer.Enabled = false; if (LastRecLong > 2) { //如果接受消息时间已经大于2秒,则认为车子掉线了。 //DelegateState.InvokeDispatchStateEvent(this.DeviceID.ToString() + "充电桩,已经掉线,将重新尝试连接..."); //通知调度程序 充电桩已经掉线 ChargeStationInfo ChargeInfo = new ChargeStationInfo(); ChargeInfo.ID = this.DeviceID; ChargeInfo.IsCommBreak = true; DelegateState.InvokeChargeChangeEvent(ChargeInfo); if (LastConnectLong > 3) { //如果车子掉线且连接时间超过3秒则需要重连 LogHelper.WriteLog("重连充电桩" + DeviceID.ToString()); ReConnect(); } } //if (LastConnectLong > 4 && LastRecLong > 3) //{ // ReConnect();//重新尝试连接 //} //if (LastRecLong > 3) //{ // //通知调度程序 充电桩已经掉线 // ChargeStationInfo ChargeInfo = new ChargeStationInfo(); // ChargeInfo.ID = this.DeviceID; // ChargeInfo.IsCommBreak = true; // DelegateState.InvokeChargeChangeEvent(ChargeInfo); //} } catch (Exception ex) { LogHelper.WriteErrorLog(ex); //DelegateState.InvokeDispatchStateEvent(this.DeviceID.ToString() + "车,观察线程异常"); } finally { communicationobserve_timer.Enabled = true; } }
/// <summary> /// 添加IO设备指令 /// </summary> public void IO_AddControl(int ioid, CommandToValue ctov) { try { IOSession_Fbell session = IOSessions.FirstOrDefault(p => p.DeviceID == ioid); if (session != null) { session.QueueCommand.Enqueue(ctov); } else { DelegateState.InvokeDispatchStateEvent("添加指令失败,未能找到" + ioid.ToString() + "号IO设备 "); } } catch (Exception ex) { DelegateState.InvokeDispatchStateEvent("添加IO设备指令异常"); } }
/// <summary> /// 添加充电桩指令 /// </summary> /// <param name="chargeid"></param> /// <param name="ctov"></param> public void Charge_AddControl(int chargeid, CommandToValue ctov) { try { AGVSessionBase session = ChargeStationSessions.FirstOrDefault(p => (p as AGVSessionBase).DeviceID == chargeid) as AGVSessionBase; if (session != null) { session.QueueCommand.Enqueue(ctov); } else { DelegateState.InvokeDispatchStateEvent("添加指令失败,未能找到" + chargeid.ToString() + "号充电桩 "); } } catch (Exception ex) { DelegateState.InvokeDispatchStateEvent("添加充电桩指令异常"); } }
/// <summary> /// 初始化 /// </summary> public virtual bool Init() { try { Clear(); Tcpsocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); Tcpsocket.ReceiveTimeout = 200; return(true); } catch (Exception ex) { CarBaseStateInfo car = new CarBaseStateInfo(); car.AgvID = this.DeviceID; car.bIsCommBreak = true; DelegateState.InvokeCarFeedbackEvent(car); return(false); } }
/// <summary> /// 初始化通信 /// </summary> /// <returns></returns> public bool Init() { try { Clear(); Tcpsocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); IsStop = false; return(true); } catch (Exception ex) { IODeviceInfo IOInfo = new IODeviceInfo(); IOInfo.ID = this.DeviceID; IOInfo.bIsCommBreak = true; DelegateState.InvokeIOFeedBackEvent(IOInfo); return(false); } }
/// <summary> /// 初始化 /// </summary> public bool Init() { try { Clear(); Tcpsocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); Tcpsocket.ReceiveTimeout = 200; return(true); } catch (Exception ex) { ChargeStationInfo io = new ChargeStationInfo(); io.ID = this.DeviceID; io.IsCommBreak = true; DelegateState.InvokeChargeChangeEvent(io); return(false); } }
private bool HandleCallBoxMonitor(CallBoxInfo CallBox, CallBoxDetail CurrBoxDetail, int staragestate, string codes = "") { try { lock (lockstorage) { #region 处理监控功能 //处理监控功能 //监控功能则为更新储位的状态 DataTable dtstorage = CoreData.dbOperator.LoadDatas("QueryAllStore"); CoreData.StorageList = DataToObject.TableToEntity <StorageInfo>(dtstorage); StorageInfo CallStore = CoreData.StorageList.FirstOrDefault(q => q.ID == CurrBoxDetail.LocationID); if (CallStore == null) { LogHelper.WriteCallBoxLog("未配置按钮盒" + CallBox.CallBoxID.ToString() + "对应的监控储位"); return(false); } int StoreState = staragestate; if (CallStore.StorageState != StoreState) { //更新数据库中的对应监控的储位状态信息 AGVServerDAccess.UpdateStorageState(StoreState, -1, CallStore.ID); if (!string.IsNullOrEmpty(codes)) { //更新备注 AGVServerDAccess.UpdteStorageRemark(CallStore.ID, codes); } //更新储位的名称 逗号分隔 CallStore.StorageState = StoreState; CallStore.Remark = codes; } return(true); #endregion } } catch (Exception ex) { DelegateState.InvokeDispatchStateEvent(ex.Message); return(false); } }
/// <summary> /// 添加AGV发送指令 /// </summary> public void AGV_AddControl(int AGVID, CommandToValue ctov) { try { AGVSessionBase session = AGVSessions.FirstOrDefault(p => (p as AGVSessionBase).DeviceID == AGVID) as AGVSessionBase; if (session != null) { //LogHelper.WriteCreatTaskLog("添加AGV:"+ AGVID.ToString()+"指令-->"+ ctov.Command.ToString()); session.QueueCommand.Enqueue(ctov); } else { DelegateState.InvokeDispatchStateEvent("添加指令失败,未能找到" + AGVID.ToString() + "号AGV通信管道!"); LogHelper.WriteLog("添加指令失败,未能找到" + AGVID.ToString() + "号AGV通信管道!"); } } catch (Exception ex) { DelegateState.InvokeDispatchStateEvent("添加指令异常"); LogHelper.WriteErrorLog(ex); } }
/// <summary> /// 重新创建连接 /// </summary> public void ReConnect() { try { LastConnectTime = DateTime.Now; if (Init()) { IODeviceInfo IOInfo = new IODeviceInfo(); IOInfo.ID = this.DeviceID; if (ReStart()) { LastConnectTime = DateTime.Now; } else { DelegateState.InvokeDispatchStateEvent("尝试连接" + this.DeviceID.ToString() + "号IO设备..."); IOInfo.bIsCommBreak = true; DelegateState.InvokeIOFeedBackEvent(IOInfo); } } else { DelegateState.InvokeDispatchStateEvent("尝试连接" + this.DeviceID.ToString() + "号IO设备..."); IODeviceInfo IOInfo = new IODeviceInfo(); IOInfo.ID = DeviceID; IOInfo.bIsCommBreak = true; DelegateState.InvokeIOFeedBackEvent(IOInfo); } } catch (Exception ex) { DelegateState.InvokeDispatchStateEvent("尝试连接" + this.DeviceID.ToString() + "号IO设备..."); IODeviceInfo IOInfo = new IODeviceInfo(); IOInfo.ID = DeviceID; IOInfo.bIsCommBreak = true; DelegateState.InvokeIOFeedBackEvent(IOInfo); } }
public bool Stop() { try { melsecMc.ConnectClose(); melsecMc.Dispose(); if (processor != null) { processor.Abort(); //解决线程过多情况,因为线程执行Abort,状态是AbortRequested,还是会存在继续执行 while (processor.ThreadState != ThreadState.Aborted) { Thread.Sleep(100); } } return(true); } catch (Exception ex) { DelegateState.InvokeDispatchStateEvent(ex.Message); return(false); } }
private bool Stop() { try { foreach (CommunicationSiemensPlc commer in Seccions) { if (!commer.Stop()) { DelegateState.InvokeDispatchStateEvent("呼叫器:" + commer.PLCCode.ToString() + "IP:" + commer.ConnParam.ServerIP + "停止失败!"); } else { DelegateState.InvokeDispatchStateEvent("呼叫器:" + commer.PLCCode.ToString() + "IP:" + commer.ConnParam.ServerIP + "停止成功!"); } } return(true); } catch (Exception ex) { DelegateState.InvokeDispatchStateEvent(ex.Message); return(false); } }
private bool InitAndStartServer() { try { DelegateState.InvokeDispatchStateEvent("正在读取数据库连接..."); ConnectConfigTool.setDBase(); if (ConnectConfigTool.DBase == null) { DelegateState.InvokeDispatchStateEvent("数据库连接文件不存在!"); return(false); } IDbOperator dbOperator = CreateDbOperator.DbOperatorInstance(ConnectConfigTool.DBase); if (dbOperator == null) { DelegateState.InvokeDispatchStateEvent("数据库连接文件不存在!"); return(false); } bool IsConnectDB = false; try { IsConnectDB = dbOperator.ServerIsThrough(); } catch (Exception ex) { DelegateState.InvokeDispatchStateEvent("数据库连接失败【" + ex.Message + "】"); } if (!IsConnectDB) { return(false); } CoreData.dbOperator = dbOperator; #region 读取系统参数 DelegateState.InvokeDispatchStateEvent("正在读取系统参数..."); DataTable dtSysparameter = CoreData.dbOperator.LoadDatas("QuerySyspara"); foreach (DataRow row in dtSysparameter.Rows) { CoreData.SysParameter[row["ParameterCode"].ToString()] = row["ParameterValue"].ToString(); } DelegateState.InvokeDispatchStateEvent("读取系统参数成功..."); #endregion DataTable dtAllCallBox = CoreData.dbOperator.LoadDatas("QueryAllCallBox"); CoreData.AllCallBoxes = DataToObject.TableToEntity <CallBoxInfo>(dtAllCallBox); DataTable dtAllCallBoxDetail = CoreData.dbOperator.LoadDatas("QueryAllCallBoxDetails"); CoreData.AllCallBoxDetail = DataToObject.TableToEntity <CallBoxDetail>(dtAllCallBoxDetail); //读取储位 DataTable dtstorage = CoreData.dbOperator.LoadDatas("QueryAllStore"); CoreData.StorageList = DataToObject.TableToEntity <StorageInfo>(dtstorage); //读取区域 DataTable dtarea = CoreData.dbOperator.LoadDatas("LoadAllArea"); CoreData.AllAreaList = DataToObject.TableToEntity <AreaInfo>(dtarea); //初始化呼叫器通信 Seccions.Clear(); foreach (CallBoxInfo callbox in CoreData.AllCallBoxes) { //if (callbox.CallBoxID != 5) //{ // continue; //} SiemensConnectInfo ConnConfig = new SiemensConnectInfo() { ServerIP = callbox.CallBoxIP, Port = callbox.CallBoxPort }; CommunicationSiemensPlc Commer = new CommunicationSiemensPlc(callbox.CallBoxID, ConnConfig); if (!Commer.InitSiemens()) { DelegateState.InvokeDispatchStateEvent("初始化呼叫器:" + callbox.CallBoxID.ToString() + "IP:" + "callbox.CallBoxIP" + "失败!"); continue; } Commer.Start(); Seccions.Add(Commer); } DelegateState.InvokeDispatchStateEvent("初始化成功..."); return(true); } catch (Exception ex) { DelegateState.InvokeDispatchStateEvent(ex.Message); return(false); } }
/// <summary> /// 启动通讯 /// </summary> public bool Start() { try { foreach (var item in AGVSessions) { new Thread(delegate() { bool StartResult = (bool)ExcuteRflectMethod(item, "Start", null); if (StartResult) { DelegateState.InvokeDispatchStateEvent(GetModelValue("DeviceID", item).ToString() + "号AGV启动通讯成功"); LogHelper.WriteLog(GetModelValue("DeviceID", item).ToString() + "号AGV启动通讯成功"); } else { try { CarInfo Car = CoreData.CarList.FirstOrDefault(p => p.AgvID == Convert.ToInt16(GetModelValue("DeviceID", item))); if (Car != null) { Car.bIsCommBreak = true; } } catch { } DelegateState.InvokeDispatchStateEvent(GetModelValue("DeviceID", item).ToString() + "号AGV启动通讯失败"); LogHelper.WriteLog(GetModelValue("DeviceID", item).ToString() + "号AGV启动通讯失败"); } }) { IsBackground = true }.Start(); } foreach (var item in ChargeStationSessions) { new Thread(delegate() { bool StartResult = (bool)ExcuteRflectMethod(item, "Start", null); if (StartResult) { DelegateState.InvokeDispatchStateEvent(GetModelValue("DeviceID", item).ToString() + "号充电桩通讯启动成功..."); } else { DelegateState.InvokeDispatchStateEvent(GetModelValue("DeviceID", item).ToString() + "号充电桩通讯启动失败..."); } }) { IsBackground = true }.Start(); } foreach (var item in IOSessions) { new Thread(delegate() { if (item.Start()) { DelegateState.InvokeDispatchStateEvent(item.DeviceID.ToString() + "号IO设备通讯启动成功..."); } else { IODeviceInfo IOInfo = CoreData.IOList.FirstOrDefault(p => p.ID == item.DeviceID); if (IOInfo != null) { IOInfo.bIsCommBreak = true; } DelegateState.InvokeDispatchStateEvent(item.DeviceID.ToString() + "号IO设备通讯启动失败..."); } }) { IsBackground = true }.Start(); } return(true); } catch (Exception ex) { DelegateState.InvokeDispatchStateEvent("设备通讯启动异常"); LogHelper.WriteErrorLog(ex); return(false); } }
/// <summary> /// SendPackIndex 为发送包序号 /// 命令反馈 /// </summary> public bool GetCallBack(Int16 SendPackIndex = 0, bool IsCheckCarState = false) { try { int AGVID = this.DeviceID; int offlinecount = 0; int allheadleftlengh = 7; int receivedlengh = 0; byte[] bufferhead = new byte[7];//定义6位长度为接收包头缓存长度 while (allheadleftlengh - receivedlengh > 0) { byte[] buffertemp = new byte[allheadleftlengh - receivedlengh]; if (Tcpsocket.Available <= 0) { continue; } int lengh = Tcpsocket.Receive(buffertemp); if (lengh <= 0) { if (offlinecount == 3) { LogHelper.WriteReciveAGVMessLog("接受的小车" + AGVID.ToString() + "反馈命令超时"); return(false); } offlinecount += 1; Thread.Sleep(50); } Buffer.BlockCopy(buffertemp, 0, bufferhead, receivedlengh, lengh); receivedlengh += lengh; } //解析AGV反馈信息 if (bufferhead[0] == 0xEB && bufferhead[1] == 0x90 && bufferhead[2] == 0XD1) { //判断一下报文序号 byte[] arr = new byte[] { bufferhead[4], bufferhead[3] }; Int16 RecvPackIndex = BitConverter.ToInt16(arr, 0); if (SendPackIndex == 0 || (SendPackIndex != 0 && RecvPackIndex == SendPackIndex))//如果发送和接受报文序号一致,说明成功 { offlinecount = 0; byte[] bytess = new byte[2] { bufferhead[6], bufferhead[5] }; //int allcontentleftlengh = bufferhead[6] << 8 + bufferhead[5]; int allcontentleftlengh = BitConverter.ToInt16(bytess, 0) + 1; receivedlengh = 0; byte[] buffercontent = new byte[allcontentleftlengh]; while (allcontentleftlengh - receivedlengh > 0) { byte[] buffertemp = new byte[allcontentleftlengh - receivedlengh]; if (Tcpsocket.Available <= 0) { continue; } int lengh = Tcpsocket.Receive(buffertemp); if (lengh <= 0) { if (offlinecount == 3) { LogHelper.WriteReciveAGVMessLog("接受的小车" + AGVID.ToString() + "反馈命令超时"); return(false); } offlinecount += 1; Thread.Sleep(50); } Buffer.BlockCopy(buffertemp, 0, buffercontent, receivedlengh, lengh); receivedlengh += lengh; } //接受完内容后校验 List <byte> msg = new List <byte>(); msg.AddRange(bufferhead); msg.AddRange(buffercontent); string SenDLog = ""; foreach (byte item in msg) { SenDLog += ((int)item).ToString("X") + " "; } LogHelper.WriteReciveAGVMessLog("接受的小车" + AGVID.ToString() + "反馈命令:" + SenDLog); byte CRC8 = CRC.CRC8(msg.Take(allcontentleftlengh + 6).ToArray()); if (CRC8 != msg[msg.Count - 1]) { LogHelper.WriteReciveAGVMessLog("接受的小车" + AGVID.ToString() + "反馈命令校验位不正确"); return(false); } //解析车辆信息 CarInfo car = new CarInfo(); car.AgvID = this.DeviceID; car.CarState = Convert.ToInt32(msg[7]); car.IsNeedFinshTask = Convert.ToInt32(msg[8]); car.IsNeedRedoTask = Convert.ToInt32(msg[9]); byte[] bytes = new byte[4] { msg[13], msg[12], msg[11], msg[10] }; car.X = BitConverter.ToInt32(bytes, 0) / 1000.00F; bytes = new byte[4] { msg[17], msg[16], msg[15], msg[14] }; car.Y = BitConverter.ToInt32(bytes, 0) / 1000.00F; bytes = new byte[4] { msg[21], msg[20], msg[19], msg[18] }; car.Angel = BitConverter.ToInt32(bytes, 0) / 1000.00F; //是否在码上 car.IsUpLand = Convert.ToInt32(msg[22].ToString()); //升降平台的状态 car.BangState = Convert.ToInt32(msg[23].ToString()); //夹持机构状态 car.JCState = Convert.ToInt32(msg[24].ToString()); //剩余电池容量 百分比 car.fVolt = Convert.ToInt32(msg[25].ToString()); //速度 car.speed = Convert.ToInt32(msg[26].ToString()); //报警长度 int WarnLen = Convert.ToInt32(msg[27].ToString()); car.ErrorMessage = ""; if (WarnLen > 0)//有报警 { int StartIndex = 27; for (int i = 1; i <= WarnLen; i++) { int Cat = StartIndex + 1; int Code = StartIndex + 2; car.WarnType = Convert.ToInt32(msg[Cat].ToString()); car.WarnBinaryCode = Convert.ToString(msg[Code], 2).PadLeft(8, '0'); switch (car.WarnType) { case 0: if (car.WarnBinaryCode.Substring(7, 1) == "1") { car.ErrorMessage += "24C02错误-写入错误!\r\n"; } if (car.WarnBinaryCode.Substring(6, 1) == "1") { car.ErrorMessage += "24C02错误-读取错误\r\n"; } break; case 1: if (car.WarnBinaryCode.Substring(7, 1) == "1") { car.ErrorMessage += "电量检测错误-通信错误\r\n"; } if (car.WarnBinaryCode.Substring(6, 1) == "1") { car.ErrorMessage += "电量检测错误-电量低\r\n"; } break; case 2: if (car.WarnBinaryCode.Substring(7, 1) == "1") { car.ErrorMessage += "WiFi通信错误-校验错误\r\n"; } if (car.WarnBinaryCode.Substring(6, 1) == "1") { car.ErrorMessage += "WiFi通信错误-心跳超时\r\n"; } break; case 3: if (car.WarnBinaryCode.Substring(7, 1) == "1") { car.ErrorMessage += "433M通信错误\r\n"; } if (car.WarnBinaryCode.Substring(6, 1) == "1") { car.ErrorMessage += "校验错误\r\n"; } break; case 4: if (car.WarnBinaryCode.Substring(7, 1) == "1") { car.ErrorMessage += "PGV100错误-校验错误1\r\n"; } if (car.WarnBinaryCode.Substring(6, 1) == "1") { car.ErrorMessage += "PGV100错误-通信超时1\r\n"; } if (car.WarnBinaryCode.Substring(5, 1) == "1") { car.ErrorMessage += "PGV100错误-硬件故障1\r\n"; } if (car.WarnBinaryCode.Substring(4, 1) == "1") { car.ErrorMessage += "PGV100错误-校验错误2\r\n"; } if (car.WarnBinaryCode.Substring(3, 1) == "1") { car.ErrorMessage += "PGV100错误-通信超时2\r\n"; } if (car.WarnBinaryCode.Substring(2, 1) == "1") { car.ErrorMessage += "PGV100错误-硬件故障2\r\n"; } break; case 5: if (car.WarnBinaryCode.Substring(7, 1) == "1") { car.ErrorMessage += "驱动器-1号通信异常\r\n"; } if (car.WarnBinaryCode.Substring(6, 1) == "1") { car.ErrorMessage += "驱动器-2号通信异常\r\n"; } if (car.WarnBinaryCode.Substring(5, 1) == "1") { car.ErrorMessage += "驱动器-3号通信异常\r\n"; } if (car.WarnBinaryCode.Substring(4, 1) == "1") { car.ErrorMessage += "驱动器-4号通信异常\r\n"; } if (car.WarnBinaryCode.Substring(3, 1) == "1") { car.ErrorMessage += "驱动器-1号硬件故障\r\n"; } if (car.WarnBinaryCode.Substring(2, 1) == "1") { car.ErrorMessage += "驱动器-2号硬件故障\r\n"; } if (car.WarnBinaryCode.Substring(1, 1) == "1") { car.ErrorMessage += "驱动器-3号硬件故障\r\n"; } if (car.WarnBinaryCode.Substring(0, 1) == "1") { car.ErrorMessage += "驱动器-3号硬件故障\r\n"; } break; case 6: if (car.WarnBinaryCode.Substring(7, 1) == "1") { car.ErrorMessage += "安全传感器-触边\r\n"; } if (car.WarnBinaryCode.Substring(6, 1) == "1") { car.ErrorMessage += "安全传感器-激光减速\r\n"; } if (car.WarnBinaryCode.Substring(5, 1) == "1") { car.ErrorMessage += "安全传感器-激光停车\r\n"; } if (car.WarnBinaryCode.Substring(4, 1) == "1") { car.ErrorMessage += "安全传感器-急停按钮\r\n"; } break; case 7: if (car.WarnBinaryCode.Substring(7, 1) == "1") { car.ErrorMessage += "SIM2000-校验错误\r\n"; } if (car.WarnBinaryCode.Substring(6, 1) == "1") { car.ErrorMessage += "SIM2000-通信超时\r\n"; } if (car.WarnBinaryCode.Substring(5, 1) == "1") { car.ErrorMessage += "SIM2000-硬件故障\r\n"; } break; case 8: if (car.WarnBinaryCode.Substring(7, 1) == "1") { car.ErrorMessage += "升降平台-未下降到位\r\n"; } if (car.WarnBinaryCode.Substring(6, 1) == "1") { car.ErrorMessage += "升降平台-未上升到位\r\n"; } break; case 9: if (car.WarnBinaryCode.Substring(7, 1) == "1") { car.ErrorMessage += "夹持机构-未夹紧到位\r\n"; } if (car.WarnBinaryCode.Substring(6, 1) == "1") { car.ErrorMessage += "夹持机构-未张开到位\r\n"; } break; case 10: if (car.WarnBinaryCode.Substring(7, 1) == "1") { car.ErrorMessage += "导航-丢失反光柱匹配\r\n"; } if (car.WarnBinaryCode.Substring(6, 1) == "1") { car.ErrorMessage += "导航-丢失定位二维码\r\n"; } if (car.WarnBinaryCode.Substring(5, 1) == "1") { car.ErrorMessage += "导航-丢失修正二维码\r\n"; } if (car.WarnBinaryCode.Substring(4, 1) == "1") { car.ErrorMessage += "导航-目标点对比异常\r\n"; } break; default: break; } StartIndex += 2; } } if (!string.IsNullOrEmpty(car.ErrorMessage)) { LogHelper.WriteAGVWarnMessLog(car.AgvID.ToString() + "号AGV报警异常信息:" + car.ErrorMessage); } LandmarkInfo CurrLand = CoreData.AllLands.FirstOrDefault(p => distance((float)p.LandX, (float)p.LandY, car.X, car.Y) <= 0.2); if (CurrLand != null) { car.CurrSite = Convert.ToInt16(CurrLand.LandmarkCode); LogHelper.WriteReciveAGVMessLog("小车" + AGVID.ToString() + "坐标得到的地标为:" + CurrLand.LandmarkCode); car.IsUpQCode = 1; } else { car.IsUpQCode = 0; } DelegateState.InvokeCarFeedbackEvent(car); LastRecTime = DateTime.Now; //发送复位需要判断车子状态是否为待命状态 if (IsCheckCarState) { LogHelper.WriteSendAGVMessLog("判断发送复位指令是否真正完成!"); if (car.CarState != 0) { LogHelper.WriteSendAGVMessLog("发送复位指令车子:" + car.AgvID.ToString() + "状态为:" + car.CarState.ToString()); return(false); } } return(true); } else { return(false); } } } catch (Exception ex) { LogHelper.WriteLog(this.DeviceID.ToString() + "车 AGV解析编解码错误!" + ex.Message); } return(false); }
public bool SendData(List <byte> bytelist, FunctionCode fc) { try { Tcpsocket.Send(bytelist.ToArray());//发送字节 if (fc == FunctionCode.Write) { Thread.Sleep(60); } int offlinecount = 0; int allheadleftlengh = 6; int receivedlengh = 0; byte[] bufferhead = new byte[6]; while (allheadleftlengh - receivedlengh > 0) { byte[] buffertemp = new byte[allheadleftlengh - receivedlengh]; int lengh = Tcpsocket.Receive(buffertemp); if (lengh <= 0) { if (offlinecount == 3) { throw new Exception("Socket 错误!"); } offlinecount += 1; Thread.Sleep(1000 * 2); } Buffer.BlockCopy(buffertemp, 0, bufferhead, receivedlengh, lengh); receivedlengh += lengh; } offlinecount = 0; receivedlengh = 0; int allcontentleftlengh = int.Parse(Convert.ToString(bufferhead[5], 10)); byte[] buffercontent = new byte[allcontentleftlengh]; while (allcontentleftlengh - receivedlengh > 0) { byte[] buffertemp = new byte[allcontentleftlengh - receivedlengh]; int lengh = Tcpsocket.Receive(buffertemp); if (lengh <= 0) { if (offlinecount == 3) { throw new Exception("Socket 错误!"); } offlinecount += 1; Thread.Sleep(1000 * 2); } Buffer.BlockCopy(buffertemp, 0, buffercontent, receivedlengh, lengh); receivedlengh += lengh; } if (fc == FunctionCode.Read && buffercontent[1] == 0x0f) { IODeviceInfo io = new IODeviceInfo(); io.ID = this.DeviceID; //解析 //1-8口 char[] bytestr = Convert.ToString(buffercontent[4], 2).PadLeft(8, '0').ToArray(); for (int i = 0; i < 8; i++) { IOPortInfo ioport = new IOPortInfo(); ioport.PortNo = 8 - i; ioport.PortState = bytestr[i] == '1' ? 1 : 0; io.DIPortList.Add(ioport); } //9-16口 bytestr = Convert.ToString(buffercontent[3], 2).PadLeft(8, '0').ToArray(); for (int i = 0; i < 8; i++) { IOPortInfo ioport = new IOPortInfo(); ioport.PortNo = 16 - i; ioport.PortState = bytestr[i] == '1' ? 1 : 0; io.DIPortList.Add(ioport); } //17-24口 bytestr = Convert.ToString(buffercontent[6], 2).PadLeft(8, '0').ToArray(); for (int i = 0; i < 8; i++) { IOPortInfo ioport = new IOPortInfo(); ioport.PortNo = 24 - i; ioport.PortState = bytestr[i] == '1' ? 1 : 0; io.DIPortList.Add(ioport); } //25-32口 bytestr = Convert.ToString(buffercontent[5], 2).PadLeft(8, '0').ToArray(); for (int i = 0; i < 8; i++) { IOPortInfo ioport = new IOPortInfo(); ioport.PortNo = 32 - i; ioport.PortState = bytestr[i] == '1' ? 1 : 0; io.DIPortList.Add(ioport); } DelegateState.InvokeIOFeedBackEvent(io); LastRecTime = DateTime.Now; return(true); } if (fc == FunctionCode.Write && buffercontent[1] == 0x0f) { LastRecTime = DateTime.Now; return(true); } return(false); } catch (Exception ex) { return(false); } }
/// <summary> /// 处理命令反馈 /// </summary> public bool GetCallBack() { try { int offlinecount = 0; int allheadleftlengh = 6; int receivedlengh = 0; byte[] bufferhead = new byte[6]; while (allheadleftlengh - receivedlengh > 0) { byte[] buffertemp = new byte[allheadleftlengh - receivedlengh]; int lengh = Tcpsocket.Receive(buffertemp); if (lengh <= 0) { if (offlinecount == 3) { throw new Exception("Socket 错误!"); } offlinecount += 1; Thread.Sleep(1000 * 2); } Buffer.BlockCopy(buffertemp, 0, bufferhead, receivedlengh, lengh); receivedlengh += lengh; } offlinecount = 0; receivedlengh = 0; int allcontentleftlengh = int.Parse(Convert.ToString(bufferhead[5], 10)); byte[] buffercontent = new byte[allcontentleftlengh]; while (allcontentleftlengh - receivedlengh > 0) { byte[] buffertemp = new byte[allcontentleftlengh - receivedlengh]; int lengh = Tcpsocket.Receive(buffertemp); if (lengh <= 0) { if (offlinecount == 3) { throw new Exception("Socket 错误!"); } offlinecount += 1; Thread.Sleep(1000 * 2); } Buffer.BlockCopy(buffertemp, 0, buffercontent, receivedlengh, lengh); receivedlengh += lengh; } //读返回 if (buffercontent[1] == 0x03) { IODeviceInfo IOInfo = new IODeviceInfo(); IOInfo.ID = this.DeviceID; //解析 1-8口 char[] bytestr = Convert.ToString(buffercontent[4], 2).PadLeft(8, '0').ToArray(); for (int i = 0; i < 8; i++) { IOPortInfo ioport = new IOPortInfo(); ioport.PortNo = 8 - i; ioport.PortState = bytestr[i] == '1' ? 1 : 0; IOInfo.DIPortList.Add(ioport); } //9-16口 bytestr = Convert.ToString(buffercontent[3], 2).PadLeft(8, '0').ToArray(); for (int i = 0; i < 8; i++) { IOPortInfo ioport = new IOPortInfo(); ioport.PortNo = 16 - i; ioport.PortState = bytestr[i] == '1' ? 1 : 0; IOInfo.DIPortList.Add(ioport); } //17-24口 bytestr = Convert.ToString(buffercontent[6], 2).PadLeft(8, '0').ToArray(); for (int i = 0; i < 8; i++) { IOPortInfo ioport = new IOPortInfo(); ioport.PortNo = 24 - i; ioport.PortState = bytestr[i] == '1' ? 1 : 0; IOInfo.DIPortList.Add(ioport); } //25-32口 bytestr = Convert.ToString(buffercontent[5], 2).PadLeft(8, '0').ToArray(); for (int i = 0; i < 8; i++) { IOPortInfo ioport = new IOPortInfo(); ioport.PortNo = 32 - i; ioport.PortState = bytestr[i] == '1' ? 1 : 0; IOInfo.DIPortList.Add(ioport); } DelegateState.InvokeIOFeedBackEvent(IOInfo); LastRecTime = DateTime.Now; return(true); } //写返回 if (buffercontent[1] == 0x10) { LastRecTime = DateTime.Now; return(true); } return(false); } catch (Exception ex) { LogHelper.WriteLog("AGV解析编解码错误!" + ex.Message); } return(false); }
/// <summary> /// 通讯初始化 /// </summary> public bool CommInit() { try { #region 小车 DispatchAssembly AgvCommunitClass = CoreData.DispathAssemblies.FirstOrDefault(p => p.AssemblyType == 0); if (AgvCommunitClass == null) { DelegateState.InvokeDispatchStateEvent("未配置AGV通信处理程序!"); LogHelper.WriteLog("未配置AGV通信处理程序!"); return(false); } DispatchAssembly ChargeCommunitClass = CoreData.DispathAssemblies.FirstOrDefault(q => q.AssemblyType == 1); if (ChargeCommunitClass == null) { DelegateState.InvokeDispatchStateEvent("未配置充电桩通信处理程序!"); LogHelper.WriteLog("未配置充电桩通信处理程序!"); return(false); } //先停止清除所有的通信管道 foreach (var item in AGVSessions) { ExcuteRflectMethod(item, "Stop", null); } AGVSessions.Clear(); //初始化所有AGV小车的通信 foreach (CarInfo car in CoreData.CarList) { AGVComPara para = new AGVComPara(); para.ServerIP = car.CarIP; para.Port = Convert.ToInt32(car.CarPort); int agvid = Convert.ToInt32(car.AgvID); Type objType = Type.GetType(AgvCommunitClass.ClassName, true); object obj = Activator.CreateInstance(objType); SetModelValue("DeviceID", agvid, obj); SetModelValue("ComPara", para, obj); //obj.DeviceID = agvid; //obj.ComPara = para; AGVSessions.Add(obj); } foreach (var item in AGVSessions) { bool InitResult = (bool)ExcuteRflectMethod(item, "Init", null); if (InitResult) { DelegateState.InvokeDispatchStateEvent(GetModelValue("DeviceID", item).ToString() + "号AGV通讯初始化成功"); LogHelper.WriteLog(GetModelValue("DeviceID", item).ToString() + "号AGV通讯初始化成功"); } else { DelegateState.InvokeDispatchStateEvent(GetModelValue("DeviceID", item).ToString() + "号AGV通讯初始化失败"); LogHelper.WriteLog(GetModelValue("DeviceID", item).ToString() + "号AGV通讯初始化失败"); } } #endregion #region 充电桩 foreach (var item in ChargeStationSessions) { ExcuteRflectMethod(item, "Stop", null); } ChargeStationSessions.Clear(); foreach (ChargeStationInfo Charge in CoreData.ChargeList) { AGVComPara para = new AGVComPara(); para.ServerIP = Charge.IP; para.Port = Convert.ToInt32(Charge.Port); int ChargeID = Convert.ToInt32(Charge.ID); Type objType = Type.GetType(ChargeCommunitClass.ClassName, true); object obj = Activator.CreateInstance(objType); SetModelValue("DeviceID", ChargeID, obj); SetModelValue("ComPara", para, obj); ChargeStationSessions.Add(obj); } foreach (var item in ChargeStationSessions) { bool InitResult = (bool)ExcuteRflectMethod(item, "Init", null); if (InitResult) { DelegateState.InvokeDispatchStateEvent(GetModelValue("DeviceID", item).ToString() + "号充电桩通讯初始化成功"); } else { DelegateState.InvokeDispatchStateEvent(GetModelValue("DeviceID", item).ToString() + "号充电桩通讯初始化失败"); } } #endregion #region io设备 foreach (var item in IOSessions) { item.Stop(); } IOSessions.Clear(); foreach (IODeviceInfo node in CoreData.IOList) { AGVComPara para = new AGVComPara(); para.ServerIP = node.IP; para.Port = Convert.ToInt32(node.Port); int ioid = Convert.ToInt32(node.ID); IOSessions.Add(new IOSession_Fbell(ioid, para)); } foreach (var item in IOSessions) { if (item.Init()) { DelegateState.InvokeDispatchStateEvent(item.DeviceID.ToString() + "号IO设备通讯初始化成功"); } else { DelegateState.InvokeDispatchStateEvent(item.DeviceID.ToString() + "号IO设备通讯初始化失败"); } } #endregion return(true); } catch (Exception ex) { DelegateState.InvokeDispatchStateEvent("初始化客户端通讯异常"); LogHelper.WriteErrorLog(ex); return(false); } }
/// <summary> /// 给一个客户提供服务,接受公司an【】 /// </summary> /// <param name="obj"></param> public void ServiceClient(object obj) { try { //lock (lockRiceve) //{ bool keepalive = true; AppSession clientsession = FindSession(obj.ToString()); if (clientsession == null) { keepalive = false; return; } DelegateState.InvokeDispatchStateEvent(clientsession._clientsocket.RemoteEndPoint.ToString() + "已连接"); try { while (keepalive) { //处理接受包 int offlinecount = 0; int allheadleftlengh = 6; int receivedlengh = 0; byte[] bufferhead = new byte[6]; while (allheadleftlengh - receivedlengh > 0) { byte[] buffertemp = new byte[allheadleftlengh - receivedlengh]; int lengh = clientsession.ClientSocket.Receive(buffertemp); if (lengh <= 0) { if (offlinecount == 3) { throw new Exception("Socket 错误!"); } offlinecount += 1; Thread.Sleep(1000 * 2); } Buffer.BlockCopy(buffertemp, 0, bufferhead, receivedlengh, lengh); receivedlengh += lengh; clientsession._lastactivedatetime = DateTime.Now; } offlinecount = 0; receivedlengh = 0; int allcontentleftlengh = int.Parse(Convert.ToString(bufferhead[5], 10)); //Convert.ToInt32(Convert.ToString(bufferhead[4], 2).PadLeft(8, '0') + Convert.ToString(bufferhead[5], 2).PadLeft(8, '0'), 2); byte[] buffercontent = new byte[allcontentleftlengh]; while (allcontentleftlengh - receivedlengh > 0) { byte[] buffertemp = new byte[allcontentleftlengh - receivedlengh]; int lengh = clientsession.ClientSocket.Receive(buffertemp); if (lengh <= 0) { if (offlinecount == 3) { throw new Exception("Socket 错误!"); } offlinecount += 1; Thread.Sleep(1000 * 2); } Buffer.BlockCopy(buffertemp, 0, buffercontent, receivedlengh, lengh); receivedlengh += lengh; clientsession._lastactivedatetime = DateTime.Now; } //List<byte> msg = buffercontent.ToList(); //记录接受日志 List <byte> msg = new List <byte>(); msg.AddRange(bufferhead); msg.AddRange(buffercontent); string log_text = ""; foreach (byte item in msg) { log_text += ((int)item).ToString("X") + " "; } string IP = ((IPEndPoint)clientsession.ClientSocket.RemoteEndPoint).Address.ToString(); LogHelper.WriteCallBoxLog("接受到IP地址为【" + IP + "】指令:" + log_text); //接受完外部指令后处理回掉处理逻辑 List <byte> CallBoxConten = new List <byte>(); CallBoxConten.AddRange(buffercontent); if (ReceiveMes != null) { ReceiveMes(new NetEventArgs(clientsession, CallBoxConten)); } } } catch (Exception ex) { LogHelper.WriteErrorLog(ex); } //} } catch (Exception ex) { LogHelper.WriteErrorLog(ex); } }