public Command(CmdType type, ActionType actType, params string[] data) { Data = new string[data.Length + 2]; Data[0] = type.ToString(); Data[1] = actType.ToString(); Array.Copy(data, 0, Data, 2, data.Length); }
private static int readVarArgOnlyCmd(CmdType cmd, string scmd, ref List <Token> ts, ref List <byte> bytes, ref List <string> vars, int i, ref int argCount) { argCount = 0; while (!isKeyWordOrProcName(ts[i]) && !Syntax.IsTokenHasOperator(ts[i], Syntax.OP_END)) { if (Syntax.IsEnumOperator(ts[i]) || ts[i].Type == TknType.NewLine) { i++; continue; } if (ts[i].Type != TknType.Word) { new CompileException(inFile(ref ts, i), inLine(ref ts, i), ErrCode.InvalidArgument, $"'{ts[i].Text}' for {scmd}"); } if (!vars.Contains(ts[i].Text)) { new CompileException(inFile(ref ts, i), inLine(ref ts, i), ErrCode.UndefinedVariable, ts[i].Text); } bytes.AddCmd(cmd, (uint)getVarID(ref vars, ts[i].Text)); argCount++; i++; } return(i); }
public RCON(CmdType tp, byte[] str) { RequestId = counter++; Type = tp; Payload = (byte[])str.Clone(); Length = Payload.Length + 2 * sizeof(int) + 2 * sizeof(byte); }
/// <summary> /// 通信命令发送前的协议格式化 /// </summary> /// <param name="str"></param> /// <returns></returns> private string FormatCmd(CmdType cmdType, DataArea areaType) { string cmdStr = "@00FA000000000"; //读写指令字符串的前缀 //先拼接读写命令 if (cmdType == CmdType.CmdRead) { cmdStr += "0101"; } else if (cmdType == CmdType.CmdWrite) { cmdStr += "0102"; } //再拼接操作区代码 if (areaType == DataArea.DMWord) { cmdStr += "82"; } else if (areaType == DataArea.WRBit) { cmdStr += "31"; } return(cmdStr); }
public Cmd(CmdType type, byte z, byte y, byte x) { this.Type = type; this.X = x; this.Y = y; this.Z = z; }
public CmdInfo(string vs, CmdType type, object data) : this() { Type = type; Data = data; validString = vs; SetToken(validString); }
private CmdType GetCmdType() { CmdType ret = CmdType.None; if (radioCustom.Checked) { ret = CmdType.Custom; } if (radioDependentProjects.Checked) { ret = CmdType.Predefined; } if (chkX86X64.Checked) { ret |= CmdType.DependentX86X64; } if (chkIntermediateFiles.Checked) { ret |= CmdType.DependentIntermediateFiles; } if (chkSeqDep.Checked) { ret |= CmdType.SeqDependentForSys; } return(ret); }
/// <summary> /// 保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(Object sender, EventArgs e) { T_UserEntity data = (T_UserEntity)ViewState["data"]; data = this.GetFormValue <T_UserEntity>(data); if (!IsEdit) { data.LastSignTime = data.JoinDate; data.Salt = TextHelper.RandomText(10); } CmdType cmd = IsEdit ? CmdType.UPDATE : CmdType.INSERT; if (db.ExecuteCommand <T_UserEntity>(data, cmd)) { if (!IsEdit) { UserName.Text = ""; } if (Admin.ID == EditID) { Admin.Update(); //如果是当前登录用户,更新用户数据 } Alert(Label1, "保存成功!", "line1px_3"); String text = String.Format("{0}用户:{1}.", IsEdit ? "编辑" : "添加", data.UserName); AppendLogs(text, IsEdit ? LogsAction.Edit : LogsAction.Create); } }
public override void Execute(INotification notification) { int mainproto = int.Parse(notification.Name); CmdType type = (CmdType)Enum.Parse(typeof(CmdType), notification.Type); if (type == CmdType.Request) { Message message = notification.Body as Message; Notify notify = new Notify(); notify.Protocol = mainproto; switch (mainproto) { case Protocol.Login: LoginReq loginReq = ReferencePool.Require <LoginReq>(); loginReq.Account = message.args[0].ToString(); loginReq.Password = message.args[1].ToString(); notify.message = loginReq.ToByteArray(); NetworkManager.SendRequest(notify); break; case Protocol.Regist: RegisterReq registerReq = ReferencePool.Require <RegisterReq>(); registerReq.Account = message.args[0].ToString(); registerReq.Password = message.args[1].ToString(); notify.message = registerReq.ToByteArray(); NetworkManager.SendRequest(notify); break; } } }
void Interp(string line) { var space = line.IndexOf(' '); string cmd, arg; if (space > 0) { cmd = line.Substring(0, space); arg = line.Substring(space + 1); } else { cmd = line; arg = string.Empty; } CmdType exec; if (CmdType.TryLookup(cmd, out exec)) { exec.DoFun(Character, arg); } else { SendToCharacter($"Huh? Command '{cmd}' not found.\n\r"); } }
/// <summary> /// 保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { if (actiontype.SelectedIndex == -1) { actiontype.SelectedIndex = 0; } T_SiteMenuEntity data = (T_SiteMenuEntity)ViewState["data"]; data = this.GetFormValue <T_SiteMenuEntity>(data); CmdType cmd = IsEdit ? CmdType.UPDATE : CmdType.INSERT; if (!IsEdit) { data.SortID = 9999; data.Layer = (data.ParentID > 0) ? 2 : 1; } if (db.ExecuteCommand <T_SiteMenuEntity>(data, cmd)) { FixLayer(); if (!IsEdit) { this.ClearFromValue(); } else { UpdateAccessControl(data); } Alert(Label1, "保存成功!", "line1px_3"); String text = String.Format("{0}菜单:{1}.", IsEdit ? "编辑" : "添加", data.Title); AppendLogs(text, IsEdit ? LogsAction.Edit : LogsAction.Create); } }
public CmdData(SRC src, CmdType name, EventDataLine eventData) { SRC = src; Name = name; EventData = eventData; ParseArgs(eventData.Data); }
private void Parse(string command) { var values = Enum.GetValues(typeof(CmdType)).Cast <CmdType>(); var desc = ""; var type = CmdType.Null; var ci = new CultureInfo("en-US"); foreach (var t in values) { desc = Utils.GetEnumDescription(t, ""); if (desc != "" && command.StartsWith(desc, true, ci)) { type = t; break; } } if (type == CmdType.Null || desc == "") { throw new CommandException("Failed to parse BECommand"); } var param = command.Remove(0, desc.Length); Type = type; Parameters = param; }
/// <summary> /// 保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { if (actiontype.SelectedIndex == -1) { actiontype.SelectedIndex = 0; } T_GroupEntity data = (T_GroupEntity)ViewState["data"]; data = this.GetFormValue <T_GroupEntity>(data); CmdType cmd = IsEdit ? CmdType.UPDATE : CmdType.INSERT; if (db.ExecuteCommand <T_GroupEntity>(data, cmd)) { FixLayer(); if (!IsEdit) { GroupName.Text = ""; } else { UpdateAccessControl(data); } Cache.Remove(ISessionKeys.cache_table_group); Cache.Remove(ISessionKeys.cache_table_accesscontrol); Alert(Label1, "保存成功!", "line1px_3"); String text = String.Format("{0}分类:{1}.", IsEdit ? "编辑" : "添加", data.GroupName); AppendLogs(text, IsEdit ? LogsAction.Edit : LogsAction.Create); } }
private IList <string> InitProcEnv(CmdType type, IEnumerable <string> env) { var ret = new List <string>(env.Count() + 3); if (!env.Contains(ENV_SLN)) { ret.Add(ENV_SLN); } if (!env.Contains(ENV_PRJ)) { ret.Add(ENV_PRJ); } if ((type & (CmdType.DependentX86X64 | CmdType.DependentIntermediateFiles)) != 0) { if (!env.Contains(MSBuildProperties.PRJ_TARGET_DIR)) { ret.Add(MSBuildProperties.PRJ_TARGET_DIR); } } ret.AddRange(env); return(ret); }
public NoUndoMWCmd(String name, CommandScope scope, bool active, MsgWin win, CmdType comType) : base(name, scope, active) { messageWindow = win; commandType = comType; }
public PreProc Configure(CmdType type = CmdType.None, string cmd = null) { Type = type; Cmd = (type == CmdType.None || cmd == null) ? string.Empty : cmd; return(this); }
public override int GetHashCode() { int hash = 1; if (CmdType.Length != 0) { hash ^= CmdType.GetHashCode(); } if (Payload.Length != 0) { hash ^= Payload.GetHashCode(); } if (Ticket.Length != 0) { hash ^= Ticket.GetHashCode(); } if (LiveId.Length != 0) { hash ^= LiveId.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
/// <summary> /// 保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(Object sender, EventArgs e) { if (!IsEdit && ChkUser(UserName.Text)) { Alert(Label1, "用户已经存在!", "line1px_2"); } else { T_UserEntity data = (T_UserEntity)ViewState["data"]; data = this.GetFormValue <T_UserEntity>(data); if (!IsEdit) { data.LastSignTime = data.JoinDate; } CmdType cmd = IsEdit ? CmdType.UPDATE : CmdType.INSERT; if (db.ExecuteCommand <T_UserEntity>(data, cmd)) { if (!IsEdit) { UserName.Text = ""; } if (Admin.ID == EditID) { Admin.Update(); //如果是当前登录用户,更新用户数据 } Alert(Label1, "保存成功!", "line1px_3"); } } }
private CmdType GetCmdType() { CmdType ret = CmdType.None; if (radioILMerge.Checked) { ret = CmdType.ILMerge; } if (radioRawExec.Checked) { ret = CmdType.Exec; } if (chkMergeConari.Checked) { ret |= CmdType.Conari; } if (chkIgnoreErrors.Checked) { ret |= CmdType.IgnoreErr; } if (chkGenDebugInfo.Checked) { ret |= CmdType.DebugInfo; } return(ret); }
// Удалить void Delete() { if (operand == "" & command == CmdType.Undef) { return; } if (operand != "") { operand = operand.Remove(operand.Length - 1); if (operand == "" & command == CmdType.Undef & actions.Count > 0) { command = (CmdType)actions[actions.Count - 1]; actions.RemoveAt(actions.Count - 1); return; } return; } if (command != CmdType.Undef) { command = CmdType.Undef; if (operand == "" & actions.Count > 0) { operand = (string)actions[actions.Count - 1]; actions.RemoveAt(actions.Count - 1); return; } return; } }
private async Task <bool> SendCmd(CmdType cmdType) { string cmd = ""; switch (cmdType) { case CmdType.TurnOffHeater: cmd = "turnoffheater"; break; case CmdType.TurnOnHeater: cmd = "turnonheater"; break; default: return(false); } HttpClient client = new HttpClient(); client.BaseAddress = new Uri(TaApiBaseAddress); client.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue("application/json")); HttpResponseMessage response = client.GetAsync(cmd).Result; if (response.IsSuccessStatusCode) { return(true); } else { return(false); } }
private void CfgPostProc() { CmdType type = Config.PostProc.Type; prj.SetProperty(MSBuildProperties.DXP_POST_PROC_TYPE, (long)type); Log.send(this, $"Post-Processing type: {type}"); if (type == CmdType.None) { return; } prj.SetProperty(MSBuildProperties.DXP_PROC_ENV, Config.PostProc.GetProcEnvAsString()); Log.send(this, $"Proc-Env: {Config.PostProc.ProcEnv}"); var target = prj.AddTarget(MSBuildTargets.DXP_POST_PROC); target.Label = Project.METALIB_PK_TOKEN; if ((type & CmdType.Custom) == CmdType.Custom) { //TODO: Log.send(this, $"Post-Processing Custom type is not fully implemented: {type}", Message.Level.Warn); return; } if ((type & (CmdType.DependentX86X64 | CmdType.DependentIntermediateFiles)) != 0) { CfgDepPostProc(AddRecursiveDependentsFor(MSBuildProperties.PRJ_TARGET_DIR, type), type); } }
public override void Execute(INotification notification) { int mainproto = int.Parse(notification.Name); CmdType type = (CmdType)Enum.Parse(typeof(CmdType), notification.Type); if (type == CmdType.Request) { Message message = notification.Body as Message; Notify notify = new Notify(); notify.Protocol = mainproto; switch (mainproto) { case Protocol.Project_Add: Project_AddReq addReq = ReferencePool.Require <Project_AddReq>(); addReq.ProjectName = message.args[0]; addReq.Priority = int.Parse(message.args[1]); addReq.Description = message.args[2]; addReq.CreateDate = message.args[3]; addReq.LimitDate = message.args[4]; notify.message = addReq.ToByteArray(); NetworkManager.SendRequest(notify); break; } } }
/// <summary> /// 构造 /// </summary> /// <param name="_cmdType">命令类型</param> /// <param name="_type">要绑定的脚本</param> /// <param name="_listener">加载完成之后的回调</param> public Command(CmdType _cmdType, string _uiName, Type _type, ILoadUIListener _listener) { cmdType = _cmdType; type = _type; listener = _listener; uiName = _uiName; }
public override void Execute(INotification notification) { int mainproto = int.Parse(notification.Name); CmdType type = (CmdType)int.Parse(notification.Type); Message message = notification.Body as Message; Notify notify = new Notify(); notify.Protocol = mainproto; if (type == CmdType.Request) { switch (mainproto) { case Protocol.UserMessage_Update: UserMessage_UpdateReq userUpdate = ReferencePool.Require <UserMessage_UpdateReq>(); userUpdate.Uid = int.Parse(message.args[0]); userUpdate.UserName = message.args[1].ToString(); userUpdate.UserAge = int.Parse(message.args[2]); userUpdate.UserProfession = message.args[3].ToString(); userUpdate.UserScore = int.Parse(message.args[4]); notify.message = userUpdate.ToByteArray(); NetworkManager.SendRequest(notify); break; } } }
public RCON(byte[] inp, bool bypassAssert = false) { var r = (byte[])inp.Clone(); //Array.Reverse(r, 0, sizeof(int)); //Array.Reverse(r, sizeof(int), sizeof(int)); //Array.Reverse(r, 2 * sizeof(int), sizeof(int)); Length = BitConverter.ToInt32(r, 0); if (inp.Length - sizeof(int) != Length && !bypassAssert) { throw new Exception("assert failed at constructor"); } RequestId = BitConverter.ToInt32(r, sizeof(int)); Type = (CmdType)BitConverter.ToInt32(r, sizeof(int)); Payload = new byte[Length - 2 * sizeof(byte) - 2 * sizeof(int)]; Array.Copy(r, 3 * sizeof(int), Payload, 0, Length - 2 * sizeof(byte) - 2 * sizeof(int)); }
private void AddTaskForX86X64(ProjectTargetElement target, CmdType type, int arch) { var tCopy = target.AddTask("Copy"); tCopy.SetParameter("SourceFiles", $"@(DllExportDirX{arch})"); tCopy.SetParameter("DestinationFolder", $@"%({GetDependentsTargetDir(type)}.Identity)x{arch}\"); tCopy.SetParameter("OverwriteReadOnlyFiles", "true"); }
private void AddTasksIntermediateFiles(ProjectTargetElement target, CmdType type, string dir) { var tCopy = target.AddTask("Copy"); tCopy.SetParameter("SourceFiles", $"@(DllExportDir{dir})"); tCopy.SetParameter("DestinationFolder", $@"%({GetDependentsTargetDir(type)}.Identity){dir}\"); tCopy.SetParameter("OverwriteReadOnlyFiles", "true"); }
private string GetDependentsTargetDir(CmdType type) { if ((type & CmdType.SeqDependentForSys) == CmdType.SeqDependentForSys) { return(MSBuildPostProc.GetNameForSeqDependentsProperty(MSBuildProperties.PRJ_TARGET_DIR)); } return(MSBuildPostProc.GetNameForDependentsProperty(MSBuildProperties.PRJ_TARGET_DIR)); }
private TeleConsoleMsg(string name, CmdType cmd, string text, ConsoleColor?bg, ConsoleColor?fg) { Name = name; Cmd = cmd; Text = text; Background = bg; Foreground = fg; }
public CmdInfo(string name, string meaning, CmdType type, byte opcode, byte funct, string inputLine) { this.name = name; this.meaning = meaning; this.type = type; this.opcode = opcode; this.funct = funct; this.inputLine = inputLine; }
public int this[CmdType ctp] { get { return m_Container[ctp]; } set { m_Container[ctp] = value; } }
public SendPackage(CmdType type, CmdClass cls, int address,byte[] text) { this.type = type; this.cls = cls; this.text = text; this.address = address; // this.BornDateTime=System.DateTime.Now; if (type == CmdType.CmdQuery) returnCmd = text[0]; if ((text[0] & 0x0f) == 0x0f) returnSubCmd = text[1]; }
public ReturnInfo ReadWithUnderlyData(CmdType ctp) { ReturnInfo r = new ReturnInfo(); string cmdString = CmdFactory.Instance.GetReadCmd(ctp); com.Write(cmdString); byte[] buffer = com.GetReceive(); if (buffer == null || buffer.Length == 0) { throw new Exception("接收超時!"); } string data = string.Empty; string underlyingData = string.Empty; data = Utils.PLCReadData(buffer, DataType.D, out underlyingData); r.ReturnValue = data; r.UnderlyingData = underlyingData; return r; }
public string Read(CmdType ctp) { string cmdString = CmdFactory.Instance.GetReadCmd(ctp); com.Write(cmdString); byte[] buffer = com.GetReceive(); if (buffer == null || buffer.Length == 0) { throw new Exception("接收超時!"); } string data = string.Empty; string underlyingData = string.Empty; data = Utils.PLCReadData(buffer, DataType.D, out underlyingData); return data; }
private void ExecuteCmd(int address, CmdType cmdType, object data) { CmdData cmddata = new CmdData(); cmddata.address = address; cmddata.cmdType = cmdType; cmddata.data = data; this.Send(cmddata); }
//****************** 执行调用 ****************************** private void comboBox1_KeyDown(object sender, KeyEventArgs e) { if (e.KeyValue == 13) { string exeUrl = ""; string vlaue = ""; try { exeUrl = comboBox1.Text; if (exeUrl.Trim() == "") return; //****************** 遍历aliase检测是否存在exe ****************************** for (int i = 0; i < comboBox1.Items.Count; i++) { ComboBoxItem cbi = (ComboBoxItem)comboBox1.Items[i]; if (exeUrl == cbi.Text) { vlaue = cbi.Value.ToString(); ct = CmdType.exe; break; } } string OutString = vlaue; int analyse_i = analyse(exeUrl, ref OutString); //****************** 输入的命令没有在aliase列表内 ****************************** if (analyse_i == 1) ct = CmdType.kill; if (analyse_i == 2) ct = CmdType.cmd; if (analyse_i == 3) ct = CmdType.stock; if (analyse_i == 4) ct = CmdType.Dos; switch (ct) { //********** 开始 运行 ********************* case CmdType.cmd: ParameterizedThreadStart ParStart = new ParameterizedThreadStart(Cmd.Run); Thread myThread = new Thread(ParStart); myThread.Start(exeUrl); //Cmd.Run(exeUrl); break; case CmdType.Dos: Cmd.Run(OutString); break; //********** kill 掉进程 ********************* case CmdType.kill: ExeProcessCmd(OutString); break; //********** 查看股票代码的网页 ********************* case CmdType.stock: string[] StockArr = exeUrl.Replace(" ","").Split(','); for (int i = 0; i < StockArr.Length; i++) { if (IsNumber(StockArr[i].ToString().Trim())) { string code = StockArr[i].Substring(0, 1) == "6" ? "sh" : "sz"; /* 搜狐网页 ShellExecute(IntPtr.Zero, "open", @"http://q.stock.sohu.com/cn/" + StockArr[i].ToString() + "/index_kp.shtml#1", "", "", ShowCommands.SW_SHOWNOACTIVATE); // //System.Diagnostics.Process.Start(@"D:\绿色软件\TheWorld1.43\TheWorldFull\TheWorld.exe", HttpArr[i].ToString()); ShellExecute(IntPtr.Zero, "open", @"http://biz.finance.sina.com.cn/suggest/lookup_n.php?q=" + StockArr[i].ToString() + "&country=stock", "", "", ShowCommands.SW_SHOWNOACTIVATE); // //System.Diagnostics.Process.Start(@"D:\绿色软件\TheWorld1.43\TheWorldFull\TheWorld.exe", HttpArr[i].ToString()); */ ShellExecute(IntPtr.Zero, "open", string.Format(@"http://quote.eastmoney.com/{0}.html", code + StockArr[i]), "", "", ShowCommands.SW_SHOWNOACTIVATE); } } break; //********** alalise 命令 ********************* case CmdType.exe: string[] HttpArr = vlaue.Split(';'); for (int i = 0; i < HttpArr.Length; i++) { if (HttpArr[i].IndexOf("://") >= 0) { ShellExecute(IntPtr.Zero, "open", HttpArr[i].ToString(), "", "", ShowCommands.SW_SHOWNOACTIVATE); // //System.Diagnostics.Process.Start(@"D:\绿色软件\TheWorld1.43\TheWorldFull\TheWorld.exe", HttpArr[i].ToString()); } else { ExeProcess(HttpArr[i].ToString()); } } break; default: break; } } catch (Exception ex) { MessageBox.Show(vlaue.ToString() + " 不存在", "消息内容", MessageBoxButtons.OK, MessageBoxIcon.Warning); Logger.Trace(ex, false); } } }
/// <summary> /// 构造函数 /// </summary> /// <param name="_cmdType">命令类型</param> /// <param name="_uiName">UI名称</param> /// <param name="_param">要传入的参数</param> public Command(CmdType _cmdType, string _uiName, object _param) { uiName = _uiName; cmdType = _cmdType; param = _param; }
public EVOCommand(CmdType type) { _CmdType = type; switch (_CmdType) { case CmdType.M2B_CMD_CLEAN: break; case CmdType.M2B_CMD_MAKE_BERVAGE: break; case CmdType.M2B_CMD_MAKE_INGREDIENT: break; case CmdType.M2B_CMD_TEST: break; case CmdType.M2B_CMD_QUERY: break; default: break; } }
public System.Data.DataSet GetSendDsByTextPackage(TextPackage txt,CmdType cmdtype) { Cmd cmd ; //if (txt.Cmd == 0x04) // cmd = getCmd((byte)txt.Cmd, txt.Text[1], cmdtype); //else // cmd = getCmd((byte)txt.Cmd, (txt.Cmd == 0x0f) ? txt.Text[1] : (byte)0xff, cmdtype); cmd = getCmdByTextPackage(txt, cmdtype); if (cmd == null) return null; else return cmd.GetSendDsByTextPackage(txt); }
public string GetReadCmd( CmdType ctp ) { int btyes = 2; if (ctp == CmdType.Yield) btyes = 4; return Command.Instance.GetReadCmd(MapperAddressRegistry.Instance[ctp], btyes); }
public byte[] GenerateBytes(int iAddress, CmdType cmdType, object data) { string[] strData; int i; int iTotalBytesCount = 13; if ((cmdType == CmdType.SendData) || (cmdType == CmdType.ShowOnly)) { strData = (string[]) data; iTotalBytesCount = 13; for (i = 0; i < strData.Length; i++) { int nCount = Encoding.Default.GetByteCount(strData[i]); iTotalBytesCount = (iTotalBytesCount + nCount) + 2; } iTotalBytesCount += 8; } else { iTotalBytesCount += 2; } int iCurrentIndex = 0; byte[] btGenerate = new byte[iTotalBytesCount]; byte[] btPrefix = new byte[this.strWritePrefix.Length / 2]; this.HexString2Bin(this.strWritePrefix, btPrefix); btPrefix.CopyTo(btGenerate, iCurrentIndex); iCurrentIndex += btPrefix.Length; byte[] btAddress = new byte[2]; this.HexString2Bin(this.FillZero(this.ConvertHexString(iAddress), 4), btAddress); btAddress.CopyTo(btGenerate, iCurrentIndex); iCurrentIndex += btAddress.Length; byte[] btBytesCount = new byte[] { (byte) iTotalBytesCount }; btBytesCount.CopyTo(btGenerate, iCurrentIndex); iCurrentIndex += btBytesCount.Length; byte[] btReserve = new byte[2]; btReserve.CopyTo(btGenerate, iCurrentIndex); iCurrentIndex += btReserve.Length; byte[] btBatch = new byte[] { 0 }; btBatch.CopyTo(btGenerate, iCurrentIndex); iCurrentIndex += btBatch.Length; byte[] btCmd = new byte[1]; this.HexString2Bin(this.FillZero(this.GetCommandCode(cmdType), 2), btCmd); btCmd.CopyTo(btGenerate, iCurrentIndex); iCurrentIndex += btCmd.Length; if ((cmdType == CmdType.SendData) || (cmdType == CmdType.ShowOnly)) { strData = (string[]) data; byte[] btDataReserve = new byte[1]; int nReserver = iCurrentIndex; btDataReserve.CopyTo(btGenerate, iCurrentIndex); iCurrentIndex += btDataReserve.Length; byte[] btDataFormat = new byte[] { this.FormatType }; btDataFormat.CopyTo(btGenerate, iCurrentIndex); iCurrentIndex += btDataFormat.Length; for (i = 0; i < strData.Length; i++) { byte[] btFont = new byte[] { this.BtRowTextSize[i] }; btFont.CopyTo(btGenerate, iCurrentIndex); iCurrentIndex += btFont.Length; byte[] btRow = new byte[Encoding.Default.GetByteCount(strData[i])]; btRow = Encoding.Default.GetBytes(strData[i]); btRow.CopyTo(btGenerate, iCurrentIndex); iCurrentIndex += btRow.Length; byte[] btEnd = new byte[] { 0 }; btEnd.CopyTo(btGenerate, iCurrentIndex); iCurrentIndex += btEnd.Length; } byte[] btKeyLight = new byte[3]; for (i = 0; i < 3; i++) { if (strData[i] == "") { btKeyLight[i] = 0; } else { btKeyLight[i] = this.btFunction[1];//(byte) (0x40 + this.KeyLightFrequency); btDataReserve[0] = (byte) (btDataReserve[0] | ((byte) Math.Pow(2.0, (double) i))); } } btKeyLight.CopyTo(btGenerate, iCurrentIndex); iCurrentIndex += btKeyLight.Length; btDataReserve.CopyTo(btGenerate, nReserver); this.btFunction.CopyTo(btGenerate, iCurrentIndex); iCurrentIndex += this.btFunction.Length; } else { byte[] btData = (byte[]) data; btData.CopyTo(btGenerate, iCurrentIndex); iCurrentIndex += btData.Length; } byte[] btFCS = new byte[2]; btFCS[1] = this.FCS(btGenerate, 2, iCurrentIndex); btFCS.CopyTo(btGenerate, iCurrentIndex); iCurrentIndex += btFCS.Length; byte[] btSuffix = new byte[this.strWriteSuffix.Length / 2]; this.HexString2Bin(this.strWriteSuffix, btSuffix); btSuffix.CopyTo(btGenerate, iCurrentIndex); iCurrentIndex += btSuffix.Length; return btGenerate; }
private string GetCommandCode(CmdType CmdType) { switch (CmdType) { case CmdType.SendData: return "20"; case CmdType.ResetElectronicLabel: return "26"; case CmdType.ControlPlateID: return "27"; case CmdType.OpenLight: return "25"; case CmdType.CloseLight: return "25"; case CmdType.LoudSpeaker: return "24"; case CmdType.ShowOnly: return "22"; case CmdType.KeyRaisedAck: return "15"; case CmdType.Delete: return "12"; case CmdType.ResetControlPlate: return "10"; } return ""; }
//just for receive // 查詢命令專用 ,主動回報 private Cmd getCmdByTextPackage(TextPackage txt,CmdType cmdtype) { Cmd cmd; byte code; switch (txt.Cmd) { case 0x04: code = txt.Text[7]; if ((code & 0x0f) != 0x0f) cmd = getCmd((byte)txt.Cmd, txt.Text[7], cmdtype); else cmd = getCmd((byte)txt.Cmd, txt.Text[7], txt.Text[8], cmdtype); break; case 0x52: if (txt.Text.Length == 2) cmd = getCmd((byte)txt.Cmd, (txt.Cmd == 0x0f) ? txt.Text[1] : (byte)0xff, cmdtype); else cmd = getCmd((byte)txt.Cmd, 0x01, cmdtype); break; case 0xb6: if (txt.Text.Length == 2) cmd = getCmd((byte)txt.Cmd, 0xff, cmdtype); else cmd = getCmd((byte)txt.Cmd, 1, cmdtype); break; case 0x5f: // mas 5f 22 if (txt.SubCmd==0x22) { if (txt.Text.Length == 4) cmd= getCmd((byte)txt.Cmd, 0x22, cmdtype); else cmd = getCmd((byte)txt.Cmd, 0xfe, cmdtype); } else if (txt.SubCmd == 0x12) //tts { if(txt.Text.Length==4) cmd = getCmd((byte)txt.Cmd, 0x12, cmdtype); else cmd = getCmd((byte)txt.Cmd, 0xfe, cmdtype); } else goto default; break; case 0xAD: if(txt.Text.Length==3) cmd = getCmd((byte)txt.Cmd, (byte)0xff, cmdtype); else cmd = getCmd((byte)txt.Cmd, 0x01, cmdtype); break; case 0xdf: if (txt.Text[1] == 0xd2 && txt.Text.Length == 3) cmd = getCmd((byte)txt.Cmd, txt.Text[1], 0x01, cmdtype); //else if (txt.Text[1] == 0xd5) //{ // if (txt.Text[10] == 0) //txt // cmd = getCmd((byte)txt.Cmd, txt.Text[1],(byte) 0x01, CmdType.CmdQuery); // else // cmd = getCmd((byte)txt.Cmd, txt.Text[1], CmdType.CmdQuery); // // if((this.findCmditem(this.ReturnCmdItems,"data_type").Min!=0 )) //graphic,or default msg // // return V2DLE.ToHexString(new byte[] { cmd, subCmd, 0x01 }).Replace(' ', '_') + this.cmdType; // //else // // return V2DLE.ToHexString(new byte[] { cmd, subCmd }).Replace(' ', '_') + this.cmdType; //} else goto default; break; default: if (this.DeviceType != "ETTU") cmd = getCmd((byte)txt.Cmd, ((txt.Cmd & 0x0f) == 0x0f) ? txt.Text[1] : (byte)0xff, cmdtype); else cmd = getCmd((byte)txt.ETTU_Cmd, txt.ETTU_SubCmd, cmdtype); break; } return cmd; }
public Cmd getCmd(byte cmd, byte subCmd, CmdType CmdType) { return(Cmd) keyhashCommands[V2DLE.ToHexString(new byte[] { cmd, subCmd }).Replace(' ', '_') + CmdType]; }
//for 04 public Cmd getCmd(byte cmd, byte protocol_code, byte sub_protocol_code, CmdType cmdtype) { return (Cmd)keyhashCommands[V2DLE.ToHexString(new byte[] { cmd, protocol_code, sub_protocol_code }).Replace(' ', '_') + cmdtype]; }
/// <summary> /// ��Э�����ɷ����ֶ� /// </summary> /// <param name="iAddress">���ӱ�ǩ��ַ</param> /// <param name="cmdType">�������Ͱ�����λ�����ƣ���ƣ������</param> /// <param name="strData">���ӱ�ǩ��Ҫ��ʾ������</param> /// <returns>�����ֶ�����</returns> public byte[] GenerateBytes(int iAddress, CmdType cmdType, object data) { #region //�����ܵ��ֽ��� int iTotalBytesCount = 13; if (cmdType == CmdType.SendData || cmdType == CmdType.ShowOnly) { //string[] strData = (string[])data; string strData = (string)data; iTotalBytesCount = 13; int nCount = System.Text.Encoding.Default.GetByteCount(strData); iTotalBytesCount = iTotalBytesCount + nCount + 2; iTotalBytesCount = iTotalBytesCount + 3; iTotalBytesCount = iTotalBytesCount + 8; } else iTotalBytesCount = iTotalBytesCount + 2; int iCurrentIndex = 0; //���������ֽ����� byte[] btGenerate = new byte[iTotalBytesCount]; //���ͷ byte[] btPrefix = new byte[strWritePrefix.Length / 2]; HexString2Bin(strWritePrefix, btPrefix); btPrefix.CopyTo(btGenerate, iCurrentIndex); iCurrentIndex = iCurrentIndex + btPrefix.Length; //��ӵ�ַ�ֶ� byte[] btAddress = new byte[2]; HexString2Bin(FillZero(ConvertHexString(iAddress), 4), btAddress); btAddress.CopyTo(btGenerate, iCurrentIndex); iCurrentIndex = iCurrentIndex + btAddress.Length; //����ֽ��� byte[] btBytesCount = new byte[1]; btBytesCount[0] = (byte)iTotalBytesCount; btBytesCount.CopyTo(btGenerate, iCurrentIndex); iCurrentIndex = iCurrentIndex + btBytesCount.Length; //��ӱ����ֶ� byte[] btReserve = new byte[2]; btReserve.CopyTo(btGenerate, iCurrentIndex); iCurrentIndex = iCurrentIndex + btReserve.Length; //������� byte[] btBatch = new byte[1]; btBatch[0] = 0; btBatch.CopyTo(btGenerate, iCurrentIndex); iCurrentIndex = iCurrentIndex + btBatch.Length; //ָ����� byte[] btCmd = new byte[1]; HexString2Bin(FillZero(GetCommandCode(cmdType), 2), btCmd); btCmd.CopyTo(btGenerate, iCurrentIndex); iCurrentIndex = iCurrentIndex + btCmd.Length; //���data�ֶ� if (cmdType == CmdType.SendData || cmdType == CmdType.ShowOnly) { //��ӱ��� string strData = (string)data; byte[] btDataReserve = new byte[1]; int nReserver = iCurrentIndex; btDataReserve.CopyTo(btGenerate, iCurrentIndex); iCurrentIndex = iCurrentIndex + btDataReserve.Length; //��Ӹ�ʽ byte[] btDataFormat = new byte[1]; btDataFormat[0] = this.FormatType; btDataFormat.CopyTo(btGenerate, iCurrentIndex); iCurrentIndex = iCurrentIndex + btDataFormat.Length; //������� //������� byte[] btFont = new byte[1]; btFont[0] = btShowColor; btFont.CopyTo(btGenerate, iCurrentIndex); iCurrentIndex = iCurrentIndex + btFont.Length; //������ byte[] btRow = new byte[System.Text.Encoding.Default.GetByteCount(strData)]; btRow = System.Text.Encoding.Default.GetBytes(strData); btRow.CopyTo(btGenerate, iCurrentIndex); iCurrentIndex = iCurrentIndex + btRow.Length; //�н��� byte[] btEnd = new byte[1]; btEnd[0] = (byte)0; btEnd.CopyTo(btGenerate, iCurrentIndex); iCurrentIndex = iCurrentIndex + btEnd.Length; //��ӹ����ֶ�3���ֽ� btFlashState.CopyTo(btGenerate, iCurrentIndex); iCurrentIndex = iCurrentIndex + btFlashState.Length; //��ӹ����ֶι�6���ֽ� btKeyLightState.CopyTo(btGenerate, iCurrentIndex); iCurrentIndex = iCurrentIndex + btKeyLightState.Length; //�ı����ֶ� //btDataReserve.CopyTo(btGenerate, nReserver); this.btFunction.CopyTo(btGenerate, iCurrentIndex); iCurrentIndex = iCurrentIndex + btFunction.Length; } else { //�������� byte[] btData = (byte[])data; //byte[] btRow = new byte[System.Text.Encoding.Default.GetByteCount(strData)]; //btRow = System.Text.Encoding.Default.GetBytes(strData); btData.CopyTo(btGenerate, iCurrentIndex); iCurrentIndex = iCurrentIndex + btData.Length; } //���У�� byte[] btFCS = new byte[2]; btFCS[1] = FCS(btGenerate, 2, iCurrentIndex); btFCS.CopyTo(btGenerate, iCurrentIndex); iCurrentIndex = iCurrentIndex + btFCS.Length; //���β�� byte[] btSuffix = new byte[strWriteSuffix.Length / 2]; HexString2Bin(strWriteSuffix, btSuffix); btSuffix.CopyTo(btGenerate, iCurrentIndex); iCurrentIndex = iCurrentIndex + btSuffix.Length; return btGenerate; #endregion }
private void Parse(string command) { var values = Enum.GetValues(typeof(CmdType)).Cast<CmdType>(); var desc = ""; var type = CmdType.Null; var ci = new CultureInfo("en-US"); foreach (var t in values) { desc = Utils.GetEnumDescription(t, ""); if (desc != "" && command.StartsWith(desc, true, ci)) { type = t; break; } } if (type == CmdType.Null || desc == "") { throw new CommandException("Failed to parse BECommand"); } var param = command.Remove(0, desc.Length); Type = type; Parameters = param; }
/// <summary> /// ����������� /// </summary> /// <param name="CmdType">��������</param> /// <returns></returns> private String GetCommandCode(CmdType CmdType) { String strReturn = ""; switch (CmdType) { case CmdType.KeyRaisedAck: strReturn = "16"; break; case CmdType.SendData: strReturn = "20"; break; case CmdType.ShowOnly: strReturn = "22"; break; case CmdType.LoudSpeaker: strReturn = "24"; break; case CmdType.OpenLight: strReturn = "25"; break; case CmdType.CloseLight: strReturn = "25"; break; case CmdType.ResetElectronicLabel: strReturn = "26"; break; case CmdType.ControlPlateID: strReturn = "27"; break; case CmdType.Delete: strReturn = "12"; break; case CmdType.ResetControlPlate: strReturn = "10"; break; default: break; } return strReturn; }
static bool sendInterprocessMsg(CmdType ct, string evidence, Dictionary<string, object> value, Dictionary<string, object> msg) { IntPtr hwnd = FindWindow(null, BC_TITLE); if (hwnd == IntPtr.Zero) { if (ServerDown != null) { ServerDown(); } return false; } else { InterprocessStruct interP = new InterprocessStruct() { Sender = WIN_TITLE, Evidence = evidence, CmdType = ((int)ct).ToString(), Values = value, Msgs = msg, }; JavaScriptSerializer jss = new JavaScriptSerializer(); jss.MaxJsonLength = int.MaxValue; var str = jss.Serialize(interP); sendMessage(hwnd, str); return true; } }
/// <summary> /// 构造 /// </summary> /// <param name="_cmdType">命令类型</param> /// <param name="_type">要绑定的脚本</param> /// <param name="_listener">加载完成之后的回调</param> public Command(CmdType _cmdType,string _uiName,Type _type,ILoadUIListener _listener) { cmdType = _cmdType; type = _type; listener = _listener; uiName = _uiName; }
public static int ToAddress(CmdType ctp) { Type type = typeof(ConstantsVar); FieldInfo field = type.GetField(ctp.ToString() + "Address"); if (field == null) return 0; object o = field.GetValue(null); if (o == null) return 0; return (int)o; }