private void startTCAProgramm(TelnetAppSession AppSession, StringRequestInfo stringRequestInfo) { if (!tCAIsOpen) { RunTimeError runTimeError = new RunTimeError(); if (tslPath.Length == 0) { AppSession.sendNoNewLine("please set the Lab PC TCA(TSL.exe) path"); return; } if (!TCAControler.startTCA(runTimeError, "localhost", tslPath)) { AppSession.sendWithAppendPropmt("open TCA fail:" + runTimeError.Errordescription); tCAIsOpen = false; return; } tCAIsOpen = true; } else { AppSession.Send("TCA instance is started, not need start again!"); } }
public static bool CreateComport(TelnetAppSession AppSession, StringRequestInfo stringRequestInfo, out int PortObjectID) { RunTimeError error = new RunTimeError(); if (!tCAIsOpen) { if (TCAControler.startTCA(error, "localhost", tslPath)) { tCAIsOpen = true; } else { AppSession.Send("startTCA error" + "\n&"); PortObjectID = 0; return(false); } } if (getParameterNumber(stringRequestInfo) != 1) { sendParameterError(AppSession); PortObjectID = 0; return(false); } string comPortName = ""; var vaildcomportList = TCAControler.getTCATPFComports(error); if (vaildcomportList.Length == 0) { AppSession.Send("Can not find vaild TCA serial port!" + "\n&"); PortObjectID = 0; return(false); } foreach (var item in vaildcomportList) { SerialPort serialPort = new SerialPort(item); try { serialPort.Open(); } catch (System.Exception ex) { serialPort.Close(); continue; } if (serialPort.IsOpen) { serialPort.Close(); comPortName = item; PortObjectID = TCAControler.CreateComport(error, getParameter(stringRequestInfo, 0), comPortName); if (!error.IsError) { ComportCreated?.Invoke(null, new Tuple <string, string>(getParameter(stringRequestInfo, 0), comPortName)); return(true); } error.Errordescription = ""; } } AppSession.Send("Create the TCA virtual serial port faild:" + error.Errordescription + "\n&"); PortObjectID = 0; return(false); }