// =========================================================================== /// \brief Define the control mode of the pendulum /// /// \param mode Controller mode // =========================================================================== public void SetControlMode(CtrlMode mode) { string [] parameters; SendQuery("SYS.SetMode.{" + Convert.ToUInt16(mode) + "}", false, out parameters); this.mode = mode; }
public void SetPortMode(uint port, CtrlMode mode) { if (mode == CtrlMode.Output) { _ioModeMap = (byte)(_ioModeMap & ~PortMask[port]); } else { _ioModeMap |= PortMask[port]; } SimpleIOClass.ConfigureIO(_ioModeMap); SimpleIOClass.WritePort(_ioStateMap); }
private bool Init(CommandPhaseModel model) { _clsState = new StatementMachine(); _listInvalidCommands = GetInvalidCommands(model.GetSelectableCommands()); _clsCommandModel = model; _iCtrlModel = CtrlMode.Surface; _isInputPossible = false; _uiCommandSurfaceList.Init(model.GetPresetCommand(), OnSelectedSurface, OnStartBattle); _uiCommandSurfaceList.isColliderEnabled = false; _uiCommandUnitSelect = UICommandUnitSelect.Instantiate(((Component)_prefabUICommandUnitSelect).GetComponent <UICommandUnitSelect>(), base.transform, model.GetSelectableCommands(), OnDecideUnitSelect, OnCancelUnitSelect); InitEnemyFleetInfos(); panel.alpha = 0f; panel.widgetsAreStatic = true; return(true); }
private void btnGetAllPortModes_Click(object sender, EventArgs e) { CtrlMode[] mode = new CtrlMode[8]; for (uint i = 0; i < 8; i++) { mode[i] = ((DIO8_MCP22)_Manager.GetCurrentController()).GetPortMode(i); } AddOutputLine(string.Format("Port Modes: {0} {1} {2} {3} {4} {5} {6} {7}", mode[0] == CtrlMode.Output ? "Output" : "Input", mode[1] == CtrlMode.Output ? "Output" : "Input", mode[2] == CtrlMode.Output ? "Output" : "Input", mode[3] == CtrlMode.Output ? "Output" : "Input", mode[4] == CtrlMode.Output ? "Output" : "Input", mode[5] == CtrlMode.Output ? "Output" : "Input", mode[6] == CtrlMode.Output ? "Output" : "Input", mode[7] == CtrlMode.Output ? "Output" : "Input" )); }
private void ThreadPoolThreadProc(object state) { ICtrl ctrlr = (ICtrl)state; uint port = 0; CtrlMode curMode = CtrlMode.Output; CtrlState curState = CtrlState.High; for (uint i = 0; i < 8; i++) { ctrlr.SetPortMode(i, curMode); } while (true) { if (!stopShow.WaitOne(0, false)) { break; } ctrlr.SetAllPortState((byte)255); for (int j = 0; j < 8; j++) { if (++port > 7) { port = 0; } ctrlr.SetPortState(port, curState); curState = curState == CtrlState.High ? CtrlState.Low : CtrlState.High; Thread.Sleep(demoDelay); } for (int k = 0; k < 3; k++) { byte tempState = 0; ctrlr.GetAllPortState(ref tempState); tempState = (byte)~tempState; ctrlr.SetAllPortState(tempState); Thread.Sleep(demoDelay * 2); } for (int l = 0; l < 8; l++) { if (--port > 7) { port = 7; //port is a uint, so it will go high instead of negative } stopShow.WaitOne(); ctrlr.SetPortState(port, curState); curState = curState == CtrlState.High ? CtrlState.Low : CtrlState.High; Thread.Sleep(demoDelay); } for (int m = 0; m < 3; m++) { byte tempState = 0; ctrlr.GetAllPortState(ref tempState); tempState = (byte)~tempState; ctrlr.SetAllPortState(tempState); Thread.Sleep(demoDelay * 2); } } }
private void btnGetPortMode_Click(object sender, EventArgs e) { CtrlMode mode = _Manager.GetCurrentController().GetPortMode((uint)numericUpDown2.Value); AddOutputLine(string.Format("The device port {0} is {1}.", numericUpDown2.Value, mode == CtrlMode.Input ? "Input" : "Output")); }