public BaseCommand(int playerID) { m_clientID = playerID; m_commandName = "BaseCommand"; m_bFinished = false; m_bRunning = false; m_commandType = ECommandType.NoCommand; }
public Command(ECommandType commandType, string commandMessage, EUserRole minimalAccessRole, string description) { CommandType = commandType; CommandMessage = commandMessage; MinimalAccessRole = minimalAccessRole; Description = description; }
public BaseCommand() { m_clientID = GlobalClient.NetWorkManager.ClientID; m_commandName = "BaseCommand"; m_bFinished = false; m_bRunning = false; m_commandType = ECommandType.NoCommand; }
public void Compute(ECommandType commandType, decimal value, bool displaySteps = true) { this.command.CommandType = commandType; this.command.Operand = value; this.command.DisplaySteps = displaySteps; this.command.Execute(); }
public static ICommand GetCommand(ECommandType type, string url) { switch (type) { case ECommandType.DownloadRepositories: return(new DownloadRepo(url)); default: return(null); } }
private bool TryParseCommand(string str, out ECommandType command) { command = default; if (!str.StartsWith("/")) { return(false); } return(Enum.TryParse(str.Substring(1), ignoreCase: true, out command)); }
public TCommand( string _command, string _verboseString, string _workingDir, string _alias, ECommandType _type, string _prjName) { command = _command; verboseString = _verboseString; workingDir = _workingDir; alias = _alias; type = _type; prjName = _prjName; }
/// <summary> /// 根据指令编码获得指令类型 /// </summary> /// <param name="bCode">指令编码</param> /// <returns></returns> public static ECommandType GetCommandTypeByCode(byte bCode) { ECommandType eCommandType = ECommandType.UnKnown; switch (bCode) { case 0x20: eCommandType = ECommandType.SwipingCard; break; case 0x32: eCommandType = ECommandType.WriteCard_Send; break; case 0x33: eCommandType = ECommandType.WriteCard_Response; break; case 0x34: eCommandType = ECommandType.ReadCard_Send; break; case 0x35: eCommandType = ECommandType.ReadCard_Response; break; case 0x36: eCommandType = ECommandType.ChsSel; break; case 0x37: eCommandType = ECommandType.ChsSelResponse; break; case 0x38: eCommandType = ECommandType.ChsClean; break; case 0x39: eCommandType = ECommandType.ChsCleanResponse; break; case 0x93: //PING应答 eCommandType = ECommandType.PingResponse; break; } return(eCommandType); }
/// <summary> /// 根据指令类型获得指令编码 /// </summary> /// <param name="CommandType">指令类型</param> /// <returns>返回0x00为未知</returns> public static byte GetCommandCodeByType(ECommandType eCommandType) { byte bRtn = 0x00; switch (eCommandType) { case ECommandType.WriteCard_Send: bRtn = 0x32; break; case ECommandType.WriteCard_Response: bRtn = 0x33; break; case ECommandType.ReadCard_Send: bRtn = 0x34; break; case ECommandType.ReadCard_Response: bRtn = 0x35; break; } return(bRtn); }
public ChatReply(SteamID address, ECommandType cmdtype) { this.address = address; this.cmdtype = cmdtype; }
public ChatReply(ECommandType cmdtype) { this.cmdtype = cmdtype; }
public ChatReply(SteamID address, string message) { this.address = address; this.message = message; cmdtype = ECommandType.Message; }
protected void WriteCommand(ECommandType commandType, string command) { LastCommand.CommandType = commandType; LastCommand.Command = command; var obj = new CommandInfo(); obj.CommandType = commandType; obj.Command = command; OnWriteData(obj); Device.WriteCommand(command); }
/// <summary> /// 检测响应包类型 /// </summary> /// <param name="bArrBag"></param> /// <param name="strErrMsg"></param> /// <returns></returns> public static ECommandType GetResponseType(byte[] bArrBag, out string strErrMsg) { ECommandType eResponseType = ECommandType.UnKnown; strErrMsg = ""; //数据校验 if (bArrBag != null && bArrBag.Length >= 6) { //1.数据CRC8校验 byte bCRCResult = CRC8A.GetCRC8(bArrBag, 0, bArrBag.Length - 1); byte bCRCSource = bArrBag[bArrBag.Length - 1]; if (bCRCSource.Equals(bCRCResult)) { //2.识别帧起始符 if (bArrBag[0].Equals(0x55) && bArrBag[1].Equals(0xFF)) { //3.识别数据长度 byte[] bArrDataLength = new byte[4]; bArrDataLength[0] = bArrBag[3]; bArrDataLength[1] = bArrBag[2]; uint iDataLength = Functions.ConverToUInt(bArrDataLength);//低字节在前,高字节在后 if (bArrBag.Length == (iDataLength + 2 + 2 + 1)) { //4.识别命令包类型 eResponseType = GetCommandTypeByCode(bArrBag[4]); if (eResponseType.Equals(ECommandType.UnKnown)) { strErrMsg = "数据包指令位不正确!"; } else if (eResponseType.Equals(ECommandType.SwipingCard)) { if (bArrBag.Length < 23) { eResponseType = ECommandType.UnKnown; } } else if (eResponseType.Equals(ECommandType.PingResponse)) { if (bArrBag.Length < 18) { eResponseType = ECommandType.UnKnown; } } } else { strErrMsg = "数据长度位与数据包实际长度不一致!"; } } else if (bArrBag[0].Equals(0x55) && bArrBag[1].Equals(0xAA)) { //刷卡头链路层ACK eResponseType = ECommandType.UnKnown; if (bArrBag.Length >= 16) { if (bArrBag[4].Equals(0x21)) { eResponseType = ECommandType.CardHeadDeviceACK; } if (bArrBag[4].Equals(0x92)) { eResponseType = ECommandType.MainDeviceACK4PingResponse; } } } else { strErrMsg = "帧起始符不正确!"; } } else { strErrMsg = "CRC校验不合法!"; } } else { strErrMsg = "数据长度不正确!"; } return(eResponseType); }
private void ProcessCommandMessage(BotUser user, ICommunicator communicator, ECommandType command) { var dialog = _dialogStorage.Get(user); if (dialog != null) { if (command == ECommandType.Cancel) { dialog = null; _dialogStorage.RemoveDialog(user); communicator.SendMessage( "Диалог отменен. Введи команду. Если нужна помошь воспользуйся командой - /help"); } else { communicator.SendMessage("Ответь на предыдущее сообщение или отмени диалог командой - /cancel"); } } else { switch (command) { case ECommandType.Register: { RegisterCommand(user, communicator); } break; case ECommandType.Cancel: { communicator.SendMessage( "Нет диалога для отмены. Введи команду. Если нужна помошь воспользуйся командой - /help"); } break; case ECommandType.Commands: { HelpCommand(user, communicator); } break; case ECommandType.BindPlayer: { BindUserCommand(user, communicator); } break; case ECommandType.ScheduleGame: { ScheduleGameCommand(user, communicator); } break; case ECommandType.CancelGame: { CancelGameCommand(user, communicator); } break; case ECommandType.AddPlayerToGame: { AddPlayerToGameCommand(user, communicator); } break; case ECommandType.Accept: { PlayerGameDeferedDecisionCommand(user, communicator, true); } break; case ECommandType.Reject: { PlayerGameDeferedDecisionCommand(user, communicator, false); } break; case ECommandType.Status: { StatusCommand(user, communicator); } break; case ECommandType.Active: { ActiveCommand(user, communicator); } break; case ECommandType.Inactive: { InactiveCommand(user, communicator); } break; case ECommandType.NextGameStatus: { NextGameStatusCommand(user, communicator); } break; case ECommandType.GameResult: { SetGameResultDialog(user, communicator); } break; case ECommandType.Authorize: { AuthorizeNewAccountCommand(user, communicator); } break; default: { throw new InvalidOperationException("Неизвестная команда"); } } } }
private void HandleSteamMessage(SteamID sender, string message, ECommandType commandType, SteamID chatRoom = null) { var i = message.IndexOf(' '); var inputCommand = i == -1 ? message : message.Substring(0, i); var command = RegisteredCommands.FirstOrDefault(cmd => cmd.Trigger.Equals(inputCommand)); if (command == null) { return; } var input = i == -1 ? string.Empty : message.Substring(i).Trim(); var commandData = new CommandArguments { CommandType = commandType, SenderID = sender, ChatRoomID = chatRoom, Message = input }; if (command.IsAdminCommand) { CommandHandler.ReplyToCommand(commandData, "This command can only be used in IRC."); return; } else if (SteamDB.IsBusy()) { CommandHandler.ReplyToCommand(commandData, "The bot is currently busy."); return; } TryCommand(command, commandData); }
internal void AddCommand(ECommandType type, Command command) { _commands.Add(type, command); }
/// <summary> /// DTXManiaGR.exe 引数の分析 /// </summary> /// <param name="arg"></param> /// <returns>DTXMania/DTXV/DTX2WAV どのモードで起動されたかを返す</returns> /// <remarks>DTXモードとして使う場合、内部でEnabled, nStartBar, Command, NeedReload, filename, last_path, last_timestampを設定する</remarks> public ECommandType ParseArguments(string arg, ref CDTXVmode cdtxv, ref CDTX2WAVmode cdtx2wav) { // -Vvvv,ppp,"soundfilename" サウンドファイルの再生 vvv=volume, ppp=pan // -S DTXV再生停止 // -D(サウンドモード)(YかNが3文字続く) Viewerの設定 // (サウンドモード) WE=WASAPI Exclusive, WS=WASAPI Shared, A1=ASIO(数値はデバイス番号), D=DSound // YYY, YNYなど 1文字目=GRmode, 2文字目=TmeStretch, 3文字目=VSyncWait // -Nxxx 再生開始小節番号 // -Etype,freq,bitrate,volBGM,volSE,volDrums,volGuitar,volBassmvolMaster,"outfilename","dtxfilename" // DTX2WAVとして使用 type="WAV"or"MP3"or"OGG", freq=48000など, bitrate=192 (kHzなど) ECommandType ret = ECommandType.DTXMania; bool analyzing = true; cdtxv.nStartBar = 0; if (arg != null) { while (analyzing) { if (arg == "") { analyzing = false; } #region [ DTXVmode ] else if (arg.StartsWith("-V", StringComparison.OrdinalIgnoreCase)) // サウンド再生 { // -Vvvv,ppp,"filename"の形式。 vvv=volume, ppp=pan. cdtxv.Enabled = true; cdtxv.Command = CDTXVmode.ECommand.Preview; cdtxv.Refreshed = true; ret = ECommandType.DTXV; arg = arg.Substring(2); int pVol = arg.IndexOf(','); //Trace.TraceInformation( "pVol=" + pVol ); string strVol = arg.Substring(0, pVol); //Trace.TraceInformation( "strVol=" + strVol ); cdtxv.previewVolume = Convert.ToInt32(strVol); //Trace.TraceInformation( "previewVolume=" + previewVolume ); int pPan = arg.IndexOf(',', pVol + 1); //Trace.TraceInformation( "pPan=" + pPan ); string strPan = arg.Substring(pVol + 1, pPan - pVol - 1); //Trace.TraceInformation( "strPan=" + strPan ); cdtxv.previewPan = Convert.ToInt32(strPan); //Trace.TraceInformation( "previewPan=" + previewPan ); arg = arg.Substring(pPan + 1); arg = arg.Trim(new char[] { '\"' }); cdtxv.previewFilename = arg; analyzing = false; } // -S -Nxxx filename else if (arg.StartsWith("-S", StringComparison.OrdinalIgnoreCase)) // DTXV再生停止 { cdtxv.Enabled = true; cdtxv.Command = CDTXVmode.ECommand.Stop; cdtxv.Refreshed = true; ret = ECommandType.DTXV; arg = arg.Substring(2); } else if (arg.StartsWith("-D", StringComparison.OrdinalIgnoreCase)) { // -DWE, -DWS, -DA1など arg = arg.Substring(2); // -D を削除 switch (arg[0]) { #region [ DirectSound ] case 'D': if (cdtxv.soundDeviceType != ESoundDeviceType.DirectSound) { cdtxv.ChangedSoundDevice = true; cdtxv.soundDeviceType = ESoundDeviceType.DirectSound; } else { cdtxv.ChangedSoundDevice = false; } arg = arg.Substring(1); break; #endregion #region [ WASAPI(Exclusive/Shared) ] case 'W': { ESoundDeviceType new_sounddevicetype; arg = arg.Substring(1); char c = arg[0]; //arg = arg.Substring(1); switch (c) { case 'E': new_sounddevicetype = ESoundDeviceType.ExclusiveWASAPI; break; case 'S': new_sounddevicetype = ESoundDeviceType.SharedWASAPI; break; default: new_sounddevicetype = ESoundDeviceType.Unknown; break; } if (cdtxv.soundDeviceType != new_sounddevicetype) { cdtxv.ChangedSoundDevice = true; cdtxv.soundDeviceType = new_sounddevicetype; } else { cdtxv.ChangedSoundDevice = false; } } arg = arg.Substring(1); break; #endregion #region [ ASIO ] case 'A': if (cdtxv.soundDeviceType != ESoundDeviceType.ASIO) { cdtxv.ChangedSoundDevice = true; cdtxv.soundDeviceType = ESoundDeviceType.ASIO; } else { cdtxv.ChangedSoundDevice = false; } arg = arg.Substring(1); int nAsioDev = 0, p = 0; while (true) { char c = arg[0]; if ('0' <= c && c <= '9') { nAsioDev *= 10; nAsioDev += c - '0'; p++; arg = arg.Substring(1); continue; } else { break; } } if (cdtxv.nASIOdevice != nAsioDev) { cdtxv.ChangedSoundDevice = true; cdtxv.nASIOdevice = nAsioDev; } break; #endregion } #region [ GRmode, TimeStretch, VSyncWait ] { // Reload判定は、-Nのところで行う cdtxv.GRmode = (arg[0] == 'Y'); cdtxv.TimeStretch = (arg[1] == 'Y'); cdtxv.VSyncWait = (arg[2] == 'Y'); arg = arg.Substring(3); } #endregion } else if (arg.StartsWith("-N", StringComparison.OrdinalIgnoreCase)) { cdtxv.Enabled = true; cdtxv.Command = CDTXVmode.ECommand.Play; ret = ECommandType.DTXV; arg = arg.Substring(2); // "-N"を除去 string[] p = arg.Split(new char[] { ' ' }); cdtxv.nStartBar = int.Parse(p[0]); // 再生開始小節 if (cdtxv.nStartBar < 0) { cdtxv.nStartBar = -1; } int startIndex = arg.IndexOf(' '); string filename = arg.Substring(startIndex + 1); // 再生ファイル名(フルパス) これで引数が終わっていることを想定 try { filename = filename.Trim(new char[] { '\"' }); cdtxv.bIsNeedReloadDTX(filename); } catch // 指定ファイルが存在しない { } arg = ""; analyzing = false; } #endregion #region [ DTX2WAV mode] else if (arg.StartsWith("-E", StringComparison.OrdinalIgnoreCase)) // DTX2WAV機能 { // -Etype,freq,bitrate,"filename"の形式。 type=WAV/OGG/MP3, freq=48000など, bitrate=192 (kbps)など. cdtx2wav.Enabled = true; ret = ECommandType.DTX2WAV; arg = arg.Substring(2); Regex re = new Regex( "(?<type>.+?),(?<freq>.+?),(?<bitrate>.+?)," + "(?<volBGM>.+?),(?<volSE>.+?),(?<volDrums>.+?),(?<volGuitar>.+?),(?<volBass>.+?),(?<volMaster>.+?)," + "(?<outfile>\"?.+\"??),(?<dtxfile>\"?.+\"??)", RegexOptions.IgnoreCase ); Match m = re.Match(arg); string strType = m.Groups["type"].Value; switch (strType.ToUpper()) { case "WAV": cdtx2wav.Format = CDTX2WAVmode.FormatType.WAV; break; case "OGG": cdtx2wav.Format = CDTX2WAVmode.FormatType.OGG; break; case "MP3": cdtx2wav.Format = CDTX2WAVmode.FormatType.MP3; break; default: cdtx2wav.Format = CDTX2WAVmode.FormatType.WAV; break; } Trace.TraceInformation("cdtx2wav.Format=" + cdtx2wav.Format.ToString()); cdtx2wav.nMixerVolume[0] = Convert.ToInt32(m.Groups["volBGM"].Value); cdtx2wav.nMixerVolume[1] = Convert.ToInt32(m.Groups["volSE"].Value); cdtx2wav.nMixerVolume[2] = Convert.ToInt32(m.Groups["volDrums"].Value); cdtx2wav.nMixerVolume[3] = Convert.ToInt32(m.Groups["volGuitar"].Value); cdtx2wav.nMixerVolume[4] = Convert.ToInt32(m.Groups["volBass"].Value); cdtx2wav.nMixerVolume[5] = Convert.ToInt32(m.Groups["volMaster"].Value); cdtx2wav.freq = Convert.ToInt32(m.Groups["freq"].Value); cdtx2wav.bitrate = Convert.ToInt32(m.Groups["bitrate"].Value); cdtx2wav.outfilename = m.Groups["outfile"].Value; cdtx2wav.dtxfilename = m.Groups["dtxfile"].Value; //パス名が長いと、コマンドラインが255文字に収まらず、ダメかな? Trace.TraceInformation("cdtx2wav.freq=" + cdtx2wav.freq); Trace.TraceInformation("cdtx2wav.bitrate=" + cdtx2wav.bitrate); Trace.TraceInformation("cdtx2wav.outfilename=" + cdtx2wav.outfilename); Trace.TraceInformation("cdtx2wav.dtxfilename=" + cdtx2wav.dtxfilename); cdtx2wav.Command = CDTX2WAVmode.ECommand.Record; analyzing = false; } #endregion // -S else if (arg.StartsWith("-C", StringComparison.OrdinalIgnoreCase)) // DTXV再生停止 { cdtx2wav.Enabled = true; cdtx2wav.Command = CDTX2WAVmode.ECommand.Cancel; ret = ECommandType.DTX2WAV; arg = arg.Substring(2); } else { analyzing = false; } } } return(ret); }
/// <summary> /// 创建发送包 /// </summary> /// <param name="CommandType">指令类型</param> /// <param name="objCard">写卡指令专用</param> /// <param name="dt">时间,同步时间专用</param> /// <param name="objDeviceAddress">地址,Ping指令专用</param> /// <param name="chs">扇区重置,写卡专用</param> /// <returns></returns> public static byte[] BuildBag(ECommandType CommandType, Card objCard = null, String chs = null, DateTime?dt = null, DeviceAddress objDeviceAddress = null) { byte[] arrRtn = new byte[0]; byte[] arrTemp; switch (CommandType) { case ECommandType.WriteCard_Send: arrTemp = BuildBag_WriteCard(objCard); if (arrTemp.Length > 0) { arrRtn = new byte[arrTemp.Length]; Array.Copy(arrTemp, arrRtn, arrRtn.Length); } break; case ECommandType.ReadCard_Send: arrRtn = new byte[6]; arrTemp = ScaleConverter.HexStr2ByteArr("55 FF 00 01 34"); Array.Copy(arrTemp, arrRtn, arrTemp.Length); arrRtn[5] = CRC8A.GetCRC8(arrTemp); break; case ECommandType.Ping: if (objDeviceAddress != null) { arrTemp = BuildBag_Ping(objDeviceAddress); if (arrTemp.Length > 0) { arrRtn = new byte[arrTemp.Length]; Array.Copy(arrTemp, arrRtn, arrRtn.Length); } } break; case ECommandType.SyncTime_Send: //同步时间 if (dt != null) { byte[] arrRtnTemp2 = BuildBag_SyncTime(Convert.ToDateTime(dt)); if (arrRtnTemp2.Length > 0) { arrRtn = new byte[arrRtnTemp2.Length]; Array.Copy(arrRtnTemp2, arrRtn, arrRtn.Length); } } break; case ECommandType.ChsSel: //扇区查询 arrTemp = BuildBag_ChsSel(); if (arrTemp.Length > 0) { arrRtn = new byte[arrTemp.Length]; Array.Copy(arrTemp, arrRtn, arrRtn.Length); } break; case ECommandType.ChsClean: //扇区重置 arrTemp = BuildBag_ChsClean(chs); if (arrTemp.Length > 0) { arrRtn = new byte[arrTemp.Length]; Array.Copy(arrTemp, arrRtn, arrRtn.Length); } break; } return(arrRtn); }
public ChatReply(SteamID address, ECommandType cmdtype, SteamID victim) { this.address = address; this.cmdtype = cmdtype; this.victim = victim; }
//============================================================================= private bool executeAllCommandsWithType(ECommandType type) { foreach (TCommand cmd in m_commands) { if (cmd.type != type || cmd.type == ECommandType.eCompile) { continue; } switch (type) { case ECommandType.eLinkStatic: CConsole.writeInfo("Link static: " + cmd.alias); break; case ECommandType.eLinkDynamic: CConsole.writeInfo("Link dynamic: " + cmd.alias); break; case ECommandType.eGenerateDsym: CConsole.writeInfo("Generate DSYM: " + cmd.alias); break; case ECommandType.eCopy: CConsole.writeInfo("Copy: " + cmd.alias); break; case ECommandType.eStrip: CConsole.writeInfo("Strip: " + cmd.alias); break; } if (m_isVerbose) { if (type == ECommandType.eCopy) { CConsole.writeVerbose("\n" + cmd.command + " -> " + cmd.verboseString); } else if (!string.IsNullOrEmpty(cmd.verboseString)) { CConsole.writeVerbose("\n" + cmd.verboseString); } } bool ok = true; if (type == ECommandType.eCopy) { int oldTick = SystemUtils.getCurrentTimeMs(); string error = null; try { File.Copy(cmd.command, cmd.verboseString, true); } catch (Exception ex) { error = ex.Message; } int duration = SystemUtils.getCurrentTimeMs() - oldTick; CConsole.writeSpentTime(" (" + (float)duration / 1000.0f + "s)"); if (error == null) { CConsole.writeSuccess(" (success)"); } else { CConsole.writeError(" (error)\n" + error); ok = false; } } else { TProcessResult pr = ProcessHelper.executeStatic(cmd.command, cmd.workingDir); if (!checkProcessResult(pr)) { ok = false; } } CConsole.writeInfo("\n\n"); if (!ok) { return(false); } } return(true); }
public ChatReply(string name, ECommandType cmdtype) { this.name = name; this.cmdtype = cmdtype; }
private void Add(string command, ECommandType commandType, EUserRole minimalUserAccessRole, string description) { _commands.Add(command, new Command(commandType, command, minimalUserAccessRole, description)); }
public Command GetCommand(ECommandType type) { return(_commands.ContainsKey(type) ? _commands[type] : null); }
public void addCommand(ECommandType type, ICommand command) { checkForFinalizedCacheReuse(); commandCache[type].Enqueue(command); }