コード例 #1
0
 // 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");
     }
 }
コード例 #2
0
        // 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);
            }
        }
コード例 #3
0
 private void exitCT11Mode(TelnetAppSession AppSession, StringRequestInfo stringRequestInfo)
 {
     //isEnterRuCommandMode = false;
     //isRunningRuCommandMode = false;
     //ruModeFSMData.ruSerialPort.stopForwardRecviThread();
     _fsmData.elevator.Fire(TelnetFSM.Events.GoBack);
 }
コード例 #4
0
 public void help(TelnetAppSession AppSession, StringRequestInfo stringRequestInfo)
 {
     foreach (var item in tcaCommandMethod)
     {
         AppSession.Send(item.Key);
     }
     AppSession.sendNoNewLine(">");
 }
コード例 #5
0
 public void startForwardRecviThread(TelnetAppSession AppSession)
 {
     telnetAppSession       = AppSession;
     recviThreadRunningFlag = true;
     recviThreadRunControl  = true;
     recviThread            = new Thread(recviandForward);
     recviThread.Start();
 }
コード例 #6
0
 private void connectedRequestPrintHelp(TelnetAppSession AppSession, StringRequestInfo stringRequestInfo)
 {
     foreach (var item in connectedRequestHandleAction)
     {
         AppSession.Send(item.Key);
     }
     AppSession.sendPropmt();
 }
コード例 #7
0
 internal void Run(TelnetAppSession AppSession, StringRequestInfo stringRequestInfo)
 {
     if (runAction != null)
     {
         runAction(AppSession, stringRequestInfo);
     }
     else
     {
         AppSession.Send("Session internal error!");
     }
 }
コード例 #8
0
        public void stopTCA(TelnetAppSession AppSession, StringRequestInfo stringRequestInfo)
        {
            RunTimeError error = new RunTimeError();

            tCAControl.stopTCA(error);
            tCAIsOpen = false;
            if (error.IsError)
            {
                AppSession.sendWithAppendPropmt(error.Errordescription);
                return;
            }
        }
コード例 #9
0
        public void restartRuToSlot(TelnetAppSession AppSession, StringRequestInfo stringRequestInfo)
        {
            if (getParameterNumber(stringRequestInfo) != 3)
            {
                sendParameterError(AppSession);
                return;
            }
            RunTimeError error = new RunTimeError();

            if (!tCAControl.restartRuToSlot(error, getParameter(stringRequestInfo, 0), getParameter(stringRequestInfo, 1), getParameter(stringRequestInfo, 2)))
            {
                AppSession.sendWithAppendPropmt("restartRuToSlot fail " + error.Errordescription);
            }
        }
コード例 #10
0
        public void DeleteAllCarriers(TelnetAppSession AppSession, StringRequestInfo stringRequestInfo)
        {
            if (getParameterNumber(stringRequestInfo) != 2)
            {
                sendParameterError(AppSession);
                return;
            }
            RunTimeError error = new RunTimeError();

            tCAControl.DeleteAllCarriers(error, getParameter(stringRequestInfo, 0), getParameter(stringRequestInfo, 1));
            if (error.IsError)
            {
                AppSession.sendWithAppendPropmt(error.Errordescription);
            }
        }
コード例 #11
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(">");
 }
コード例 #12
0
 public void runAction(TelnetAppSession AppSession, StringRequestInfo stringRequestInfo)
 {
     if (stringRequestInfo.Key.Length == 0)
     {
         AppSession.sendPropmt();
     }
     else if (connectedRequestHandleAction.ContainsKey(stringRequestInfo.Key))
     {
         connectedRequestHandleAction[stringRequestInfo.Key](AppSession, stringRequestInfo);
     }
     else
     {
         AppSession.Send(@"Unkonw Command, Please use [" + "help" + "] list the vaild command");
         AppSession.sendPropmt();
     }
 }
コード例 #13
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);
     }
 }
コード例 #14
0
        public void SetCPCfile(TelnetAppSession AppSession, StringRequestInfo stringRequestInfo)
        {
            if (getParameterNumber(stringRequestInfo) != 2)
            {
                sendParameterError(AppSession);
                return;
            }
            RunTimeError error = new RunTimeError();

            string[] paramMeter = stringRequestInfo.Parameters;
            tCAControl.SetCPCfile(error, paramMeter[0], paramMeter[1]);
            if (error.IsError)
            {
                AppSession.sendWithAppendPropmt(error.Errordescription);
                return;
            }
        }
コード例 #15
0
        public void CpcListFiles(TelnetAppSession AppSession, StringRequestInfo stringRequestInfo)
        {
            if (getParameterNumber(stringRequestInfo) != 1)
            {
                sendParameterError(AppSession);
                return;
            }
            RunTimeError error = new RunTimeError();

            string[] paramMeter = stringRequestInfo.Parameters;
            string   data       = tCAControl.CpcListFiles(error, paramMeter[0]);

            if (error.IsError)
            {
                AppSession.sendWithAppendPropmt(error.Errordescription);
                return;
            }
        }
コード例 #16
0
        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);
        }
コード例 #17
0
 public void runAction(TelnetAppSession AppSession, StringRequestInfo stringRequestInfo)
 {
     if (stringRequestInfo.Key.Length != 0 && RuModeActionDic.ContainsKey(stringRequestInfo.Key))
     {
         RuModeActionDic[stringRequestInfo.Key](AppSession, stringRequestInfo);
         return;
     }
     if (!isEnterRuCommandMode)
     {
         isEnterRuCommandMode = true;
         ruModeFSMData.ruSerialPort.startForwardRecviThread(AppSession);
     }
     if (!isRunningRuCommandMode)
     {
         isRunningRuCommandMode = true;
         ruModeFSMData.ruSerialPort.resumeForwardRecviThread();
     }
     ruForward(stringRequestInfo);
 }
コード例 #18
0
        private void tryEnterRuCommandsMode(TelnetAppSession AppSession, StringRequestInfo stringRequestInfo)
        {
            if (!connectedfSMData.ruSerialPort.isOpen)
            {
                RunTimeError runTimeError = new RunTimeError();
                if ((stringRequestInfo.GetFirstParam().Length == 0 && connectedfSMData.comPortName == null) ||
                    !SerialPort.GetPortNames().ToList().Contains(connectedfSMData.comPortName))
                {
                    printHelp();
                    return;
                }
                else if (stringRequestInfo.GetFirstParam().Length > 0 && !connectedfSMData.ruSerialPort.openComport(stringRequestInfo.GetFirstParam(), runTimeError))
                {
                    AppSession.sendWithAppendPropmt(string.Format("open serial port:{0} fail: " + runTimeError.Errordescription, stringRequestInfo.GetFirstParam()));
                    return;
                }
                else if (stringRequestInfo.GetFirstParam().Length == 0 && SerialPort.GetPortNames().ToList().Contains(connectedfSMData.comPortName))
                {
                    if (!connectedfSMData.ruSerialPort.openComport(connectedfSMData.comPortName, runTimeError))
                    {
                        AppSession.sendWithAppendPropmt(string.Format("open serial port:{0} fail: " + runTimeError.Errordescription, connectedfSMData.comPortName));
                        return;
                    }
                }
                else if (stringRequestInfo.GetFirstParam().Equals("Portlist"))
                {
                    foreach (var item in RuSerialPort.getSerialPortList())
                    {
                        AppSession.Send(item);
                    }
                    AppSession.sendPropmt();
                    return;
                }
                this.connectedfSMData.elevator.Fire(Events.RuCommand);
            }
            this.connectedfSMData.elevator.Fire(Events.RuCommand);

            void printHelp()
            {
                AppSession.sendWithAppendPropmt("RuCommand [ Portlist | serial name[COM3]]");
            }
        }
コード例 #19
0
        public void getHwSn(TelnetAppSession AppSession, StringRequestInfo stringRequestInfo)
        {
            if (getParameterNumber(stringRequestInfo) != 0)
            {
                sendParameterError(AppSession);
                return;
            }
            RunTimeError error = new RunTimeError();

            string[] hwSn = tCAControl.getHwSn(error);
            if (error.IsError)
            {
                AppSession.sendWithAppendPropmt(error.Errordescription);
                return;
            }
            foreach (var item in hwSn)
            {
                AppSession.Send(item);
            }
        }
コード例 #20
0
        public void SetCarrierConfig(TelnetAppSession AppSession, StringRequestInfo stringRequestInfo)
        {
            if (getParameterNumber(stringRequestInfo) != 13)
            {
                sendParameterError(AppSession);
                return;
            }
            RunTimeError error = new RunTimeError();

            string[] paramMeter = stringRequestInfo.Parameters;
            tCAControl.SetCarrierConfig(error, paramMeter[0], paramMeter[1],
                                        paramMeter[2], paramMeter[3], paramMeter[4], paramMeter[5], paramMeter[6],
                                        paramMeter[7], paramMeter[8], paramMeter[9], paramMeter[10],
                                        paramMeter[11], paramMeter[12]);
            if (error.IsError)
            {
                AppSession.sendWithAppendPropmt(error.Errordescription);
                return;
            }
        }
コード例 #21
0
        public void IQFilesGetList(TelnetAppSession AppSession, StringRequestInfo stringRequestInfo)
        {
            if (getParameterNumber(stringRequestInfo) != 1)
            {
                sendParameterError(AppSession);
                return;
            }
            RunTimeError error = new RunTimeError();

            string[] paramMeter = stringRequestInfo.Parameters;
            string[] data       = tCAControl.IQFilesGetList(error, paramMeter[0]);
            if (error.IsError)
            {
                AppSession.sendWithAppendPropmt(error.Errordescription);
                return;
            }
            foreach (var item in data)
            {
                AppSession.Send(item);
            }
        }
コード例 #22
0
 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!");
     }
 }
コード例 #23
0
 private void tryTCAIcolish(TelnetAppSession AppSession, StringRequestInfo stringRequestInfo)
 {
     this.connectedfSMData.elevator.Fire(Events.TCAIcolishCommand);
 }
コード例 #24
0
 private void tryEnterCT11Mode(TelnetAppSession AppSession, StringRequestInfo stringRequestInfo)
 {
     this.connectedfSMData.elevator.Fire(Events.CT11Command);
 }
コード例 #25
0
 private void ruSerialPortSendAndRecvi(StringRequestInfo stringRequestInfo, TelnetAppSession AppSession)
 {
     _fsmData.ruSerialPort.send(stringRequestInfo.Parameters.ToList().ToString());
     AppSession.sendNoNewLine(_fsmData.ruSerialPort.recviUntilPropmt());
 }
コード例 #26
0
 public void SessionRequsetHandle(TelnetAppSession session, StringRequestInfo stringRequestInfo)
 {
     telnetFSM.Run(session, stringRequestInfo);
 }
コード例 #27
0
 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("&");
     }
 }
コード例 #28
0
 private void exitIcolishMode(TelnetAppSession AppSession, StringRequestInfo stringRequestInfo)
 {
     _fsmData.elevator.Fire(TelnetFSM.Events.GoBack);
 }
コード例 #29
0
 private bool openVirtualChannel(TelnetAppSession AppSession, StringRequestInfo stringRequestInfo, out int PortObjectID)
 {
     return(TCACommandWarpper.CreateComport(AppSession, stringRequestInfo, out PortObjectID));
 }
コード例 #30
0
 private void ct11CommandSend(TelnetAppSession AppSession, StringRequestInfo stringRequestInfo)
 {
     ruModeFSMData.ruSerialPort.suspendForwardRecviThread();
     isRunningRuCommandMode = false;
     ruModeFSMData.tCACommand.callTCACommand(AppSession, stringRequestInfo);
 }