public void StartingMotor(int index) { byte[] Serial_Num = new byte[100]; //开启索引为0的电机 int ret = motorRun(Serial_Num, index, (int)MotorType.TwoWireMotor);//0成功 Thread.Sleep(1000); ret = motorPoll(Serial_Num); /* 状态 * "峰值电流:" + (Serial_Num[5] * 256 + Serial_Num[6]) + "mA 平均电流:" + (Serial_Num[7] * 256 + Serial_Num[8]) + "mA 运行时间:" + (Serial_Num[9] * 256 + Serial_Num[10]) + "mS\r\n" */ while (true) { ret = motorPoll(Serial_Num); if (ret == 3) { break; } } JObject jo = new JObject( new JProperty("retCode", true), new JProperty("callback", "getBoxState")); scriptInvoker.ScriptInvoke(jo); }
private void ReadCallback(IAsyncResult ar) { JObject jo = (JObject)ar.AsyncState; try { ((RunAsyncCaller)((AsyncResult)ar).AsyncDelegate).EndInvoke(ar); } catch (Exception e) { jo["result"] = ErrorCode.Failure; log.Error("Error", e); } finally { isBusy = false; int t = jo.Value <int>("timeout"); if (864000000 == t) { if (ErrorCode.Offline != jo.Value <int>("result")) { scriptInvoker.ScriptInvoke(jo); } if (!cancelled) { Thread.Sleep(200); JObject joo = new JObject(); joo["objId"] = jo["objId"]; joo["callback"] = jo["callback"]; joo["tag"] = jo["tag"]; joo["type"] = jo["type"]; joo["timeout"] = t; ReadAsync(joo); } } else { RunCompletedEvent(this, new RunCompletedEventArgs(jo)); } } }
private void ReadQRCodeCompletedEvent(object sender, RunCompletedEventArgs e) { scriptInvoker.ScriptInvoke((JObject)e.Result); }
public void Read(JObject jo) { while (nOpend > 0) { StringBuilder cValue = new StringBuilder(); int ret = sUNSON_ScanKeyPress(cValue); /* * 1、在明文状态下,获取的按键键值为明文键值(0:0x30 1:0x31 2:0x32 3:0x33 * 4:0x34 5:0x35 6:0x36 7:0x37 8:0x38 9:0x39 00:0x30 取消:0x1b 更正: * 0x08 确认:0x0D 。对应的 8 个功能键键值依次 0x41 0x42 0x43 0x44 0x45 * 0x46 0x47 0x48) * 2、在密文状态下输入的数字键,获取的是字符‘*’号,键值 0x2a。功能键键 * 值与明文状态相同。 * 3、在明文状态下或 PIN 输入状态,当到达指定的字符输入长度时,回送结束键 */ if (ret > 0) //textBox4.Text += cValue[0]; { switch (cValue[0]) { case (char)0x1B: //取消 sUNSON_CloseEppPlainTextMode(cValue); break; case (char)0x08: //更正 break; case (char)0x0D: //确认 break; case '?': sUNSON_CloseEppPlainTextMode(cValue); break; case 'T': //上翻 break; case '#': //下翻 break; case '.': //0 jo["value"] = cValue[0].ToString(); jo["model"] = "Text"; jo["callback"] = "displayValue"; scriptInvoker.ScriptInvoke(jo); break; case (char)0x30: //0 jo["value"] = cValue[0].ToString(); jo["model"] = "Text"; jo["callback"] = "displayValue"; scriptInvoker.ScriptInvoke(jo); break; case (char)0x31: //1 jo["value"] = cValue[0].ToString(); jo["model"] = "Text"; jo["callback"] = "displayValue"; scriptInvoker.ScriptInvoke(jo); break; case (char)0x32: //2 jo["value"] = cValue[0].ToString(); jo["model"] = "Text"; jo["callback"] = "displayValue"; scriptInvoker.ScriptInvoke(jo); break; case (char)0x33: //3 jo["value"] = cValue[0].ToString(); jo["model"] = "Text"; jo["callback"] = "displayValue"; scriptInvoker.ScriptInvoke(jo); break; case (char)0x34: //4 jo["value"] = cValue[0].ToString(); jo["model"] = "Text"; jo["callback"] = "displayValue"; scriptInvoker.ScriptInvoke(jo); break; case (char)0x35: //5 jo["value"] = cValue[0].ToString(); jo["callback"] = "displayValue"; scriptInvoker.ScriptInvoke(jo); break; case (char)0x36: //6 jo["value"] = cValue[0].ToString(); jo["model"] = "Text"; jo["callback"] = "displayValue"; scriptInvoker.ScriptInvoke(jo); break; case (char)0x37: //7 jo["value"] = cValue[0].ToString(); jo["model"] = "Text"; jo["callback"] = "displayValue"; scriptInvoker.ScriptInvoke(jo); break; case (char)0x38: //8 jo["value"] = cValue[0].ToString(); jo["model"] = "Text"; jo["callback"] = "displayValue"; scriptInvoker.ScriptInvoke(jo); break; case (char)0x39: //9 jo["value"] = cValue[0].ToString(); jo["model"] = "Text"; jo["callback"] = "displayValue"; scriptInvoker.ScriptInvoke(jo); break; case '*': jo["value"] = cValue[0].ToString(); jo["model"] = "CipherText"; jo["callback"] = "displayValue"; scriptInvoker.ScriptInvoke(jo); break; default: break; } } Thread.Sleep(50); } }