private void GSensor_Load(object sender, EventArgs e) { UInt16 LastErrCode; // Get library version byte[] byLibVersion = new byte[GSensor_API.IMC_LIB_VERSION_SIZE]; LastErrCode = GSensor_API.GSENSOR_GetLibVersion(byLibVersion); if (LastErrCode != IMC_ERR_NO_ERROR) { MessageBox.Show("Fails to get library version"); return; } int nRealSize; StaticLibVersionValue.Text = ConvertByte2String(byLibVersion, byLibVersion.Length, out nRealSize); comboBoxGsensorResValue.Items.Add("+-2G"); comboBoxGsensorResValue.Items.Add("+-4G"); comboBoxGsensorResValue.Items.Add("+-8G"); comboBoxGsensorResValue.Items.Add("+-16G"); comboBoxGsensorResValue.SelectedIndex = 0; listViewGsensorData.Columns.Add("X", 50, HorizontalAlignment.Left); listViewGsensorData.Columns.Add("Y", 50, HorizontalAlignment.Left); listViewGsensorData.Columns.Add("Z", 50, HorizontalAlignment.Left); GSensorAlarmEvent = System_API.CreateEvent((IntPtr)null, false, false, null); GSensorThreadActive = true; GSensorAlarmHandleThread = new Thread(GSensorAlarmProcess); GSensorAlarmHandleThread.IsBackground = true; GSensorAlarmHandleThread.Start(); }
public MessageReport Update(string _id, System_API obj) { var report = new MessageReport(); try { var query = Builders <System_API> .Filter.Eq(e => e._id, _id); var update = Builders <System_API> .Update .Set(x => x.Name, obj.Name) .Set(x => x.Controller, obj.Controller) .Set(x => x.Action, obj.Action) .Set(x => x.ParamsName, obj.ParamsName) .Set(x => x.MethodType, obj.MethodType) .Set(x => x.IsActive, obj.IsActive); _System_APIRepository.Update(query, update); report.Success = true; report.Message = "Cập nhật API thành công!"; } catch (Exception ex) { report.Message = ex.Message; } return(report); }
public void GSensorAlarmProcess() { GSensorThreadRunning = true; while (GSensorThreadActive) { System_API.WaitForSingleObject(GSensorAlarmEvent, 1000); if (GSensorAlarmActive && GSensorThreadActive) { this.Invoke(new ShowGSensorAlarmDataFunction(GSensorGetAlarmData)); } } GSensorThreadRunning = false; }
private void GSensor_FormClosing(object sender, FormClosingEventArgs e) { Debug.WriteLine("FormClosing"); GSensorThreadActive = false; while (GSensorThreadRunning) { System_API.SetEvent(GSensorAlarmEvent); Thread.Sleep(100); } TkBarGSensorStatus.Value = 0; System_API.CloseHandle(GSensorAlarmEvent); }
public MessageReport Create(System_API obj) { var rp = new MessageReport(); try { _System_APIRepository.Add(obj); rp.Success = true; rp.Message = "Thêm API thành công!"; } catch (Exception ex) { rp.Message = ex.Message; } return(rp); }
/// <summary> /// 键盘功能按键响应 /// </summary> void keyBoard_KeyFunctionEvent(string keycode) { switch (keycode) { case AppCode.TAB: //定位按钮切换Tab按键 System_API.keybd_event(Keys.Tab, 0, 0, 0); System_API.keybd_event(Keys.Tab, 0, 0x02, 0); break; case AppCode.ENTER: //定位按钮切换Tab按键 System_API.keybd_event(Keys.Enter, 0, 0, 0); System_API.keybd_event(Keys.Enter, 0, 0x02, 0); break; case AppCode.Upper: KeyBoardStateCache.CapsLock = !KeyBoardStateCache.CapsLock; KeyBoardStateCache.KeyBoard.SetMainKeyboardLedStatus(0, KeyBoardStateCache.CapsLock); System_API.keybd_event(Keys.CapsLock, 0, 0, 0); System_API.keybd_event(Keys.CapsLock, 0, 0x02, 0); break; case AppCode.Language: if (!KeyBoardStateCache.IsEN) //中文 { KeyBoardStateCache.IsEN = true; //英文 KeyBoardStateCache.KeyBoard.SetMainKeyboardLedStatus(1, false); KeyBoardStateCache.KeyBoard.SetMainKeyboardLedStatus(2, true); } else { //切换中文 英文LED关闭,大写LED关闭 ,中文LED开启 KeyBoardStateCache.IsEN = false; //中文 KeyBoardStateCache.KeyBoard.SetMainKeyboardLedStatus(2, false); KeyBoardStateCache.KeyBoard.SetMainKeyboardLedStatus(1, true); } //切换中英文,大写灯自动关闭 KeyBoardStateCache.KeyBoard.SetMainKeyboardLedStatus(0, false); KeyBoardStateCache.CapsLock = false; //模拟键盘Shift切换中英文输入法 System_API.keybd_event(Keys.ShiftKey, 0, 0, 0); System_API.keybd_event(Keys.ShiftKey, 0, 0x02, 0); break; case AppCode.Symbol: //符号键模拟 Control+Shift+Z 调取搜狗输入法符号页面 System_API.keybd_event(Keys.ControlKey, 0, 0, 0); System_API.keybd_event(Keys.ShiftKey, 0, 0, 0); System_API.keybd_event(Keys.Z, 0, 0, 0); System_API.keybd_event(Keys.ControlKey, 0, 0x02, 0); System_API.keybd_event(Keys.ShiftKey, 0, 0x02, 0); System_API.keybd_event(Keys.Z, 0, 0x02, 0); break; case AppCode.Coordination: this.ControlXiaoMai(); break; default: Dispatcher.BeginInvoke((Action) delegate { Messenger.Default.Send <AppCodeMessage>(new AppCodeMessage() { AppCode = keycode }); }, System.Windows.Threading.DispatcherPriority.Send); break; } }
/// <summary> /// 键盘标准按键响应 /// </summary> void keyBoard_KeyStandardEvent(uint keycode, uint fnkeys) { //模拟键盘输入 if (fnkeys == 1) { switch (keycode) { case 48: //0 keycode = 188; //, System_API.keybd_event((Keys)keycode, 0, 0, 0); System_API.keybd_event((Keys)keycode, 0, 2, 0); break; case 49: //1 keycode = 189; //- System_API.keybd_event((Keys)keycode, 0, 0, 0); System_API.keybd_event((Keys)keycode, 0, 2, 0); break; case 50: //2 keycode = 186; //: System_API.keybd_event(Keys.ShiftKey, 0, 0, 0); System_API.keybd_event((Keys)keycode, 0, 0, 0); System_API.keybd_event((Keys)keycode, 0, 2, 0); System_API.keybd_event(Keys.ShiftKey, 0, 2, 0); break; case 51: //3 keycode = 187; //= System_API.keybd_event((Keys)keycode, 0, 0, 0); System_API.keybd_event((Keys)keycode, 0, 2, 0); break; case 52: //4 keycode = 57; //( System_API.keybd_event(Keys.ShiftKey, 0, 0, 0); System_API.keybd_event((Keys)keycode, 0, 0, 0); System_API.keybd_event((Keys)keycode, 0, 2, 0); System_API.keybd_event(Keys.ShiftKey, 0, 2, 0); break; case 53: //5 keycode = 111; //、 System_API.keybd_event((Keys)keycode, 0, 0, 0); System_API.keybd_event((Keys)keycode, 0, 2, 0); break; case 54: //6 keycode = 48; //) System_API.keybd_event(Keys.ShiftKey, 0, 0, 0); System_API.keybd_event((Keys)keycode, 0, 0, 0); System_API.keybd_event((Keys)keycode, 0, 2, 0); System_API.keybd_event(Keys.ShiftKey, 0, 2, 0); break; case 55: //7 keycode = 53; //% System_API.keybd_event(Keys.ShiftKey, 0, 0, 0); System_API.keybd_event((Keys)keycode, 0, 0, 0); System_API.keybd_event((Keys)keycode, 0, 2, 0); System_API.keybd_event(Keys.ShiftKey, 0, 2, 0); break; case 56: //8 keycode = 186; //; System_API.keybd_event((Keys)keycode, 0, 0, 0); System_API.keybd_event((Keys)keycode, 0, 2, 0); break; case 57: //9 keycode = 56; //* System_API.keybd_event(Keys.ShiftKey, 0, 0, 0); System_API.keybd_event((Keys)keycode, 0, 0, 0); System_API.keybd_event((Keys)keycode, 0, 2, 0); System_API.keybd_event(Keys.ShiftKey, 0, 2, 0); break; default: break; } } else { if (keycode == 188) { keycode = 187; System_API.keybd_event(Keys.ShiftKey, 0, 0, 0); System_API.keybd_event((Keys)keycode, 0, 0, 0); System_API.keybd_event((Keys)keycode, 0, 2, 0); System_API.keybd_event(Keys.ShiftKey, 0, 2, 0); } else { Keys key = (Keys)keycode; System_API.keybd_event(key, 0, 0, 0); System_API.keybd_event(key, 0, 0x02, 0); } } }