// using the reflection get the command function and to run
 public void callTCACommand(TelnetAppSession AppSession, StringRequestInfo stringRequestInfo)
 {
     if (stringRequestInfo.Key == "help")
     {
         help(AppSession, stringRequestInfo);
         return;
     }
     if (!tCAIsOpen)
     {
         AppSession.Send("TCA is not running, start TCA...");
         startTCAProgramm(AppSession, stringRequestInfo);
         if (tCAIsOpen)
         {
             AppSession.Send("TCA start finished");
         }
         else
         {
             AppSession.Send("TCA start error");
         }
     }
     if (tcaCommandMethod.ContainsKey(stringRequestInfo.Key))
     {
         object[] parameters = new object[] { AppSession, stringRequestInfo };
         tcaCommandMethod[stringRequestInfo.Key].Invoke(this, parameters);
     }
     else
     {
         AppSession.sendNoNewLine("can not find this command");
     }
 }
Beispiel #2
0
 public void runAction(TelnetAppSession AppSession, StringRequestInfo stringRequestInfo)
 {
     if (stringRequestInfo.Key.Length != 0)
     {
         if (CT11ModeActionDic.ContainsKey(stringRequestInfo.Key))
         {
             CT11ModeActionDic[stringRequestInfo.Key](AppSession, stringRequestInfo);
             AppSession.sendNoNewLine("\r>");
             return;
         }
         tCACommandWarpper.callTCACommand(AppSession, stringRequestInfo);
         AppSession.sendNoNewLine("\r>");
         return;
     }
     AppSession.sendNoNewLine(">");
 }
        // error How to transfer lmc to lab pc
        public void loadLMC(TelnetAppSession AppSession, StringRequestInfo stringRequestInfo)
        {
            if (getParameterNumber(stringRequestInfo) != 3)
            {
                sendParameterError(AppSession);
                return;
            }
            RunTimeError error    = new RunTimeError();
            string       fileName = System.IO.Path.GetFileName(stringRequestInfo.GetFirstParam());
            const String dirName  = "/RecviFile/";

            fileName = Environment.CurrentDirectory + dirName + fileName;
            if (!System.IO.File.Exists(fileName))
            {
                AppSession.sendNoNewLine(string.Format("Load LMC fail, The special LMC file: {0} is not exist on server local PC",
                                                       System.IO.Path.GetFileName(stringRequestInfo.GetFirstParam())));
                return;
            }
            string CpriPort  = getParameter(stringRequestInfo, 1);
            string IsRestart = getParameter(stringRequestInfo, 2);

            if (!tCAControl.loadLMC(error, fileName, CpriPort, IsRestart))
            {
                AppSession.sendWithAppendPropmt(error.Errordescription);
            }
        }
 public void help(TelnetAppSession AppSession, StringRequestInfo stringRequestInfo)
 {
     foreach (var item in tcaCommandMethod)
     {
         AppSession.Send(item.Key);
     }
     AppSession.sendNoNewLine(">");
 }
Beispiel #5
0
 private void RuCommandSend(TelnetAppSession AppSession, StringRequestInfo stringRequestInfo)
 {
     if (_fsmData.ruSerialPort.isOpen)
     {
         ruSerialPortSendAndRecvi(stringRequestInfo, AppSession);
     }
     else
     {
         RunTimeError runTimeError = new RunTimeError();
         if (!_fsmData.ruSerialPort.openComport(_fsmData.comPortName, runTimeError))
         {
             AppSession.sendNoNewLine("open comport failed,please check the comport number!");
             return;
         }
         ruSerialPortSendAndRecvi(stringRequestInfo, AppSession);
     }
 }
        public void CpriGetFsInfo_RX(TelnetAppSession AppSession, StringRequestInfo stringRequestInfo)
        {
            if (getParameterNumber(stringRequestInfo) != 2)
            {
                sendParameterError(AppSession);
                return;
            }
            RunTimeError error = new RunTimeError();

            string[] paramMeter = stringRequestInfo.Parameters;
            string   getdata    = tCAControl.CpriGetFsInfo_RX(error, paramMeter[0], paramMeter[1]);

            if (error.IsError)
            {
                AppSession.sendWithAppendPropmt(error.Errordescription);
                return;
            }
            AppSession.sendNoNewLine(getdata);
        }
 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!");
     }
 }
Beispiel #8
0
 private void ruSerialPortSendAndRecvi(StringRequestInfo stringRequestInfo, TelnetAppSession AppSession)
 {
     _fsmData.ruSerialPort.send(stringRequestInfo.Parameters.ToList().ToString());
     AppSession.sendNoNewLine(_fsmData.ruSerialPort.recviUntilPropmt());
 }
 public void runAction(TelnetAppSession AppSession, StringRequestInfo stringRequestInfo)
 {
     if (stringRequestInfo.Key.Length != 0)
     {
         if (stringRequestInfo.Key == "ExitIcolishMode")
         {
             exitIcolishMode(AppSession, stringRequestInfo);
         }
         if (!_isEnterMode)
         {
             if (stringRequestInfo.Key == "OpenVirtualChannel")
             {
                 RunTimeError runTimeError = new RunTimeError();
                 string       cpriPort     = stringRequestInfo.GetFirstParam();
                 string       comPortName  = "";
                 int          objectID     = 0;
                 if (!ComportDic.ContainsKey(cpriPort))
                 {
                     if (!openVirtualChannel(AppSession, stringRequestInfo, out objectID))
                     {
                         return;
                     }
                 }
                 ComportDic[cpriPort].Second = objectID;
                 comPortName = (string)ComportDic[cpriPort].First;
                 if (isOpen)
                 {
                     ruSerialPort.stopForwardRecviThread();
                     ruSerialPort.close();
                     isOpen = false;
                 }
                 if (openComPort(runTimeError, comPortName))
                 {
                     isOpen = true;
                     ruSerialPort.startForwardRecviThread(AppSession);
                     _isEnterMode = true;
                 }
                 else
                 {
                     AppSession.Send(runTimeError.Errordescription + "\n&");
                 }
             }
             else
             {
                 AppSession.Send("please OpenVirtualChannel: OpenVirtualChannel [CpriPort] \r\n\t like:  OpenVirtualChannel 1A \n&");
             }
         }
         else
         {
             string cmd = "";
             if (stringRequestInfo.GetFirstParam().Length > 0)
             {
                 cmd = stringRequestInfo.Key + " " + stringRequestInfo.Body;
             }
             else
             {
                 cmd = stringRequestInfo.Key;
             }
             ruSerialPort.send(cmd);
         }
     }
     else
     {
         AppSession.sendNoNewLine("&");
     }
 }