Ejemplo n.º 1
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("&");
     }
 }
Ejemplo n.º 2
0
        private void TCACommandWarpper_ComportCreated(object sender, Tuple <string, string> e)
        {
            Pair pair = new Pair(e.Item2, 0);

            ComportDic.Add(e.Item1, pair);
        }