Esempio n. 1
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();
     }
 }
Esempio n. 2
0
 private void connectedRequestPrintHelp(TelnetAppSession AppSession, StringRequestInfo stringRequestInfo)
 {
     foreach (var item in connectedRequestHandleAction)
     {
         AppSession.Send(item.Key);
     }
     AppSession.sendPropmt();
 }
Esempio n. 3
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]]");
            }
        }