private void HandleInterrupts() { var enabledInterrupts = memory.ReadByte(INTERRUPT_ENABLE_ADDR); var requestedInterrupts = memory.ReadByte(INTERRUPT_FLAG_ADDR); if (InterruptMasterEnableFlag) { for (int i = 0; i < (int)Interrupt.Joypad && InterruptMasterEnableFlag; i++) { if (requestedInterrupts.IsBitSet(i) && enabledInterrupts.IsBitSet(i)) { powerMode = PowerMode.Normal; InterruptMasterEnableFlag = false; requestedInterrupts = BitUtils.SetBit(requestedInterrupts, i, false); memory.WriteByte(INTERRUPT_FLAG_ADDR, requestedInterrupts); Tick(); jumpUnit.Call(interruptVector[(Interrupt)i], ref SP, ref PC); Tick(); } } } else if (powerMode == PowerMode.Halt) { if ((enabledInterrupts & requestedInterrupts & 0x1F) != 0) { powerMode = PowerMode.Normal; } } }
/// <summary> /// Set the output power of the VisiLED controller. /// </summary> /// <param name="channel">The channel to apply the new power setting too.</param> /// <param name="mode">The power mode to set the power for (normal or strobe).</param> /// <param name="power">The % power to apply to the channel (0-100).</param> public void SetPower(Channel channel, PowerMode mode, double power) { var boundPower = Math.Max(Math.Min(power, 100.0), 0.0); var commandString = mode == PowerMode.Strobe ? $"{CommandCase(channel, "p")}{boundPower * 3}" : $"{CommandCase(channel, "i")}{boundPower}"; SendCommand(commandString, 0, true); }
public void SetPowerMode(PowerMode mode) { switch (mode) { case PowerMode.On: if (_statePowerMode == PowerMode.PoweredDown) { _c.SendCommand("CP", 1); } else { _c.SendIdle(); Thread.Sleep(15); } break; case PowerMode.PoweredDown: _c.SendCommand("CP", 0); break; case PowerMode.Sleep: _c.SendCommand("SL"); break; case PowerMode.DeepSleep: _c.SendCommand("DS"); break; } _statePowerMode = mode; }
public void Set(List <CheckInfo> gen, List <CheckInfo> chk) { General = gen; Check = chk; TbContestName.Text = General.GetByName("ContestName"); CbCategory.Items.Clear(); var sects = Sectors.ToArray(General.GetByName("Sectors")).ToList(); foreach (var cat in sects) { if (cat != null) { CbCategory.Items.Add("(" + cat.Code + ")" + cat.WrittenName); } } CbCategory.IsEnabled = CbCategory.Items.Count > 0 ? true : false; WpPower.Children.Clear(); var pows = PowerMode.ToArray(General.GetByName("PowerMode")).ToList(); foreach (var mod in pows) { WpPower.Children.Add(new RadioButton() { Content = mod.Name, GroupName = "PowerMode" }); } TbCoeff.IsEnabled = chk.GetByName("CoeffSetting").ToBool(); TbMainContestNo.IsEnabled = chk.GetByName("AreaNoExists").ToBool(); TbSubContestNo.IsEnabled = !chk.GetByName("AreaByFreq").IsEmpty(); }
/// <summary> /// Gets the value for the specified power plan, power mode and setting /// </summary> /// <param name="plan">Guid of the power plan</param> /// <param name="subgroup">The subgroup to look in</param> /// <param name="setting">The settign to look up</param> /// <param name="powerMode">Power mode. AC or DC, but not both.</param> /// <returns>The active index value for the specified setting</returns> public static uint GetPlanSetting(Guid plan, Guid subgroup, Guid setting, PowerMode powerMode) { if (powerMode == (PowerMode.AC | PowerMode.DC)) { throw new ArgumentException("Can't get both AC and DC values at the same time, because they may be different."); } uint value = 0; uint res = 0; if (powerMode.HasFlag(PowerMode.AC)) { res = PowerReadACValueIndex(IntPtr.Zero, ref plan, ref subgroup, ref setting, out value); } else if (powerMode.HasFlag(PowerMode.DC)) { res = PowerReadDCValueIndex(IntPtr.Zero, ref plan, ref subgroup, ref setting, out value); } if (res != (uint)ErrorCode.SUCCESS) { throw new Win32Exception((int)res); } return(value); }
/// <summary> /// Set Power Mode /// </summary> /// <param name="mode">Power Mode</param> public void SetPowerMode(PowerMode mode) { ce.Write(GpioPinValue.Low); byte[] value = new byte[1]; sensor.TransferSequential(new byte[] { R_REGISTER + CONFIG }, value); byte setting; switch (mode) { case PowerMode.UP: setting = (byte)(value[0] | (1 << 1)); break; case PowerMode.DOWN: setting = (byte)(value[0] & ~(1 << 1)); break; default: setting = (byte)(value[0] | (1 << 1)); break; } sensor.Write(new byte[] { W_REGISTER + CONFIG, setting }); ce.Write(GpioPinValue.High); }
private void Start(PowerMode mode) { var mainWindow = new MainWindow(mode, this); mainWindow.Show(); mainWindow.Closed += (o, e) => this.Show(); this.Hide(); }
public void Power(PowerMode mode) { uint data = m_hmc.ReadRegister(HMC704LP4E_REGS.RST); m_allRegs.reg1Rst = BF.CreateBitField <REG1_RST>(data); //m_allRegs.reg1Rst.EnFromSPI = (uint)mode; m_hmc.WriteRegister(HMC704LP4E_REGS.RST, m_allRegs.reg1Rst.ToUInt32()); }
/// <summary> /// Sets the power mode to the given mode /// </summary> /// <param name="powerMode"></param> public void SetPowerMode(PowerMode powerMode) { byte status = Read8BitsFromRegister((byte)Register.CTRL_MEAS); //clear last two bits status = (byte)(status & 0b1111_1100); status = (byte)(status | (byte)powerMode); _i2cDevice.Write(new[] { (byte)Register.CTRL_MEAS, status }); }
/// <summary> /// Set the power mode. /// </summary> /// <param name="powerMode">The <see cref="PowerMode"/> to set.</param> public void SetPowerMode(PowerMode powerMode) { var register = Register.Ctrl_meas; byte read = Read8Bits(register); // Clear first 2 bits. var cleared = (byte)(read & 0b_1111_1100); _i2cDevice.Write(new[] { (byte)register, (byte)(cleared | (byte)powerMode) }); }
private void OnPowerModeMenuComboBox_ItemChange(object sender, EventArgs e) { if (clicker != null) { string item = PowerModeMenu.SelectedItem.ToString(); PowerMode itemAsPowerMode = item.ToEnum <PowerMode>(); string description = itemAsPowerMode.GetEnumDescription(); toolTip1.SetToolTip(PowerModeMenu, description); clicker.Mode = itemAsPowerMode; } }
private void ResetState() { // Protocol and Serial _statePollMode = false; _stateSerialDelay = 0; _statePacketSkipRate = 0; _statePacketFiltering = false; _stateLineModeTrack = 0; _stateLineModeMean = 0; _stateLineModeDiff = 0; _stateOutputMask.Clear(); _stateFrameStreaming = false; // Configuration _stateFrameBuffer = false; _statePowerMode = PowerMode.On; _stateSlaveCameraType = CameraType.OV6620; _stateHighResolution = false; _stateFrameDifferencingChannel = Channel.Green; _stateFrameDifferencingHighRes = false; _stateNoiseFilter = 2; _statePixelDifference = false; _stateTrackInverted = false; _stateLed1 = LedMode.Auto; _stateLed2 = LedMode.Auto; _stateDownsampleX = 1; _stateDownsampleY = 1; _stateWindow = GetVirtualWindow(); _stateFullFrameSize = new Size(_stateWindow.Width, _stateWindow.Height); _stateHistogramBins = HistogramBinCount.Bins28; _stateHistogramScale = 0; _stateHistogramTracking = false; // Servo _stateServoPanFar = 16; _stateServoPanNear = 8; _stateServoPanStep = 5; _stateServoTiltFar = 16; _stateServoTiltNear = 8; _stateServoTiltStep = 5; for (int i = 0; i < _stateServoHigh.Length; i++) { _stateServoHigh[i] = false; } ResetRegistersState(); ReloadState(); }
/// <summary> /// Create a new instance. /// </summary> /// <param name="lnbIndex">Zero based index of the LNB the channel should be bound to.</param> /// <param name="uFrequency">Frequency.</param> /// <param name="eInversion">Spectrum inversion.</param> /// <param name="uSymbolRate">Symbol rate.</param> /// <param name="ePower">Polarisation selection.</param> /// <param name="eViterbi">[Don't know]</param> /// <exception cref="ArgumentOutOfRangeException">The LNB index is negative or greater than 3.</exception> public SatelliteChannel(int lnbIndex, uint uFrequency, SpectrumInversion eInversion, uint uSymbolRate, PowerMode ePower, Viterbi eViterbi, bool DVBS2) : base(uFrequency, eInversion) { // Verify if ( (lnbIndex < 0) || (lnbIndex > 3) ) throw new ArgumentOutOfRangeException("lnbIndex", lnbIndex, "Must not be less than zero or greater than 3"); // Remember SymbolRate = uSymbolRate; S2Modulation = DVBS2; LNBIndex = lnbIndex; Viterbi = eViterbi; Power = ePower; }
public MainWindow(PowerMode mode, Form powerModeWindow) { InitializeComponent(); _mode = mode; _lastForm = powerModeWindow; switch (_mode) { case PowerMode.High: PowerModeLabel.Text = "工作模式:高功率"; break; case PowerMode.Medium: PowerModeLabel.Text = "工作模式:中功率"; break; case PowerMode.Low: PowerModeLabel.Text = "工作模式:低功率"; break; } }
/// <summary> /// Set Power Mode /// </summary> /// <param name="mode">Power Mode</param> public void SetPowerMode(PowerMode mode) { var cfg = Nrf24L01Config.Read(this); if (cfg.Power != mode) { cfg.Power = mode; cfg.Persist(this); if (mode == PowerMode.PowerUp) { MicrosecondTimer.Wait(1600); // according to docs, need to wait only for 1500 } } }
public void Initialize(DataRate ouputDataRate = DataRate._95Hz, AxisSelection axisSelection = AxisSelection.All, PowerMode powerMode = PowerMode.Active, HighPassFilterMode hpMode = HighPassFilterMode.Normal, HighPassConfiguration hpConfiguration = HighPassConfiguration.HPConf0, Scale scale = Scale._0250, LowPass2Mode lpMode = LowPass2Mode.Bypassed) { // we are setting the 5 control registers in a single SPI write operation // by taking advantage on the consecutive write capability byte[] configBuffer = new byte[5]; // control register 1 configBuffer[0] = (byte)axisSelection; configBuffer[0] |= (byte)powerMode; configBuffer[0] |= (byte)ouputDataRate; // control register 2 if (hpMode != HighPassFilterMode.Bypassed) { configBuffer[1] = (byte)hpConfiguration; } // control register 3 skipped // control register 4 configBuffer[3] = (byte)scale; // TDB // block auto-update // endianess // control register 5 if (hpMode != HighPassFilterMode.Bypassed) { // high pass filter enabled configBuffer[4] = 0x10; if (lpMode != LowPass2Mode.Bypassed) { configBuffer[4] |= 0x08 | 0x02; } else { configBuffer[4] |= 0x04 | 0x01; } } WriteOperation(ControlRegister1, configBuffer); }
private byte FetchOpcode() { var code = memory.ReadByte(PC); if (powerMode == PowerMode.HaltBug) { powerMode = PowerMode.Normal; } else { PC++; } Tick(); return(code); }
void FinishComponentInitialization() { ActiveControl = InfoLbl; StopButt.Text = PauseButtonRunningText; BackColor = GlobalBackColor; foreach (var mode in (PowerMode[])Enum.GetValues(typeof(PowerMode))) { PowerModeMenu.Items.Add(mode.ToString()); } PowerMode normalMode = PowerMode.Normal; PowerModeMenu.Text = normalMode.ToString(); toolTip1.SetToolTip(PowerModeMenu, normalMode.GetEnumDescription()); }
public EditPowerMode(CheckInfo src) { Result = null; tmp = src; InitializeComponent(); var apm = PowerMode.ToArray(src.Data); if (apm != null) { modes = new ObservableCollection <PowerMode>(apm); } else { modes = new ObservableCollection <PowerMode>(); } DgModes.ItemsSource = modes; }
/// <summary> /// Alters a setting on a power plan. /// </summary> /// <param name="plan">The Guid for the plan you are changing</param> /// <param name="subgroup">The Guid for the subgroup the setting belongs to</param> /// <param name="setting">The Guid for the setting you are changing</param> /// <param name="powerMode">You can chose to alter the AC value, the DC value or both using the bitwise OR operator (|) to join the flags.</param> /// <param name="value">The new value for the setting. Run <code>powercfg -q</code> from the command line to list possible values</param> public static void SetPlanSetting(Guid plan, Guid subgroup, Guid setting, PowerMode powerMode, uint value) { if (powerMode.HasFlag(PowerMode.AC)) { var res = PowerWriteACValueIndex(IntPtr.Zero, ref plan, ref subgroup, ref setting, value); if (res != (uint)ErrorCode.SUCCESS) { throw new Win32Exception((int)res); } } if (powerMode.HasFlag(PowerMode.DC)) { var res = PowerWriteDCValueIndex(IntPtr.Zero, ref plan, ref subgroup, ref setting, value); if (res != (uint)ErrorCode.SUCCESS) { throw new Win32Exception((int)res); } } }
/// <summary> /// 获取电源配置命令的字节数组 /// </summary> /// <param name="ch">配置电源的通道</param> /// <param name="mode">对应通道的工作模式</param> /// <param name="vset">DCDC模式下的输出电压,单位‘毫伏’</param> /// <param name="targetId"></param> /// <returns></returns> public byte[] PowersupplyConfig(PowersupplyChannel ch, PowerMode mode, int vset = 5000, int targetId = 0) { byte[] ar = null; UInt16 crc; PowersupplyConfigCmd cmd = new PowersupplyConfigCmd(); byte ctrlcode = 0x01; if (PowersupplyChannel.ChannelAll == ch) { ctrlcode = 0xff; } InitHeader(typeof(PowersupplyConfigCmd), (CmdHeader)cmd, ctrlcode, TYPE_POWER, (UInt16)targetId); cmd.mode = (byte)mode; cmd.channel = (byte)ch; cmd.Vset_h = (byte)(vset >> 8); cmd.Vset_l = (byte)(vset & 0xff); ar = Struct2Array <PowersupplyConfigCmd>(cmd); crc = CalcCRC16(0, ar, ar.Length - 2); ar[ar.Length - 2] = (byte)(crc >> 8); ar[ar.Length - 1] = (byte)(crc & 0xff); return(ar); }
public static ProcessStartInfo GetStartInfo(PowerMode powermode, CurrentType ct, bool enable) { var info = new ProcessStartInfo(); info.FileName = "powercfg"; info.CreateNoWindow = true; // コンソール・ウィンドウを開かない info.UseShellExecute = false; // シェル機能を使用しない string args = string.Empty; switch (powermode) { case PowerMode.Sleep: args += "-change -standby-timeout"; break; case PowerMode.Display: args += "-change -monitor-timeout"; break; } switch (ct) { case CurrentType.AC: args += "-dc "; break; case CurrentType.DC: args += "-ac "; break; } args += (autodisplayoff ? "1" : "0"); info.Arguments = args; return(info); }
/// <summary> /// Wake up procedure /// </summary> private async Task WakeUp() { switch (powerMode) { case PowerMode.Normal: // nothing break; case PowerMode.PowerDown: // TODO : wake up needed or nothing ? // this.commLayer.WakeUp(); break; case PowerMode.LowVbat: // PN532 Application Note C106 pag. 23 // wake up needed await commLayer.WakeUp(); // SAM Configuration in normal mode command is needed (pn532um.pdf, pag. 13) byte[] cmd = { PN532_SAM_CONFIGURATION, (byte)SamMode.NormalMode, 0x00, 0x00 }; // send cmd and check acknowledge if (await SendNormalFrame(cmd)) { byte[] response = ReadNormalFrame(); } break; default: break; } powerMode = PowerMode.Normal; }
public MainWindow(PowerMode mode, Form powerModeWindow) { InitializeComponent(); _control = ControlClass.GetInstance(); _mode = mode; _lastForm = powerModeWindow; switch (_mode) { case PowerMode.High: PowerModeLabel.Text = "工作模式:高功率"; break; case PowerMode.Medium: PowerModeLabel.Text = "工作模式:中功率"; Calibrate.Enabled = true; break; case PowerMode.Low: PowerModeLabel.Text = "工作模式:低功率"; break; } _control.StartPreview(AnglePicture, ShiftPicture); img = _control.imageX; UpDateTask.Start(); }
/// <summary> /// Constructor /// </summary> /// <param name="commLayer">Communication layer to use</param> public PN532(IPN532CommunicationLayer commLayer) { this.commLayer = commLayer; this.powerMode = PowerMode.LowVbat; }
/// <summary> /// Constructor /// </summary> /// <param name="commLayer">Communication layer to use</param> public PN532(IPN532CommunicationLayer commLayer) { this.commLayer = commLayer; powerMode = PowerMode.LowVbat; }
private string MakeSummery(CheckData check) { string log = "<SUMMARYSHEET VERSION=R2.0>\r\n"; try { if (check.Gens.GetByName("ContestName").IsEmpty()) { return(null); } log += "<CONTESTNAME>" + check.Gens.GetByName("ContestName") + "</CONTESTNAME>\r\n"; log += "<CATEGORYCODE>"; var catidx = ConfigGeneral.GetCategoryIndex(check.ConGen.Category, check.Gens); if (catidx != -1) { log += Sectors.ToArray(check.Gens.GetByName("Sectors")).ToArray()[catidx].Code; } else { return(null); } if (check.ConGen.PowerModeArg != -1) { log += PowerMode.ToArray(check.Gens.GetByName("PowerMode"))[check.ConGen.PowerModeArg].SuffixPowerSign; } log += "</CATEGORYCODE>\r\n"; log += "<CALLSIGN>" + check.ConSol.CallSign + "</CALLSIGN>\r\n"; if (check.ConSol.GestOp != "") { log += "<OPCALLSIGN>" + check.ConSol.GestOp + "</OPCALLSIGN>\r\n"; } log += "<TOTALSCORE>" + SumPoint + "</TOTALSCORE>\r\n"; log += "<ADDRESS>" + check.ConSol.Address + "</ADDRESS>\r\n"; log += "<NAME>" + check.ConSol.Name + "</NAME>\r\n"; log += "<TEL>" + check.ConSol.PhoneNumber + "</TEL>\r\n"; log += "<EMAIL>" + check.ConSol.MailAddress + "</EMAIL>\r\n"; log += "<POWER>" + check.ConGen.PowerValue + "</POWER>\r\n"; if (check.Ches.GetByName("CoeffSetting").ToBool()) { log += "<FDCOEFF>" + check.ConGen.Coeff + "</FDCOEFF>\r\n"; } log += "<OPPLACE>" + check.ConSol.Place + "</OPPLACE>\r\n"; log += "<POWERSUPPLY>" + check.ConSol.Supply + "</POWERSUPPLY>\r\n"; log += "<COMMENTS>" + check.ConSol.Comment + "</COMMENTS>\r\n"; if (check.ConGen.AutoOperator) { log += "<MULTIOPLIST>" + string.Join(",", check.Logs.Select(x => x.Operator).Distinct()) + "</MULTIOPLIST>\r\n"; } else { log += "<MULTIOPLIST>" + check.ConGen.Operators + "</MULTIOPLIST>\r\n"; } log += "<OATH>" + check.ConSol.Oath + "</OATH>\r\n"; log += "<DATE>" + System.DateTime.Now.ToLocalTime().ToString("yyyy年MM月dd日") + "</DATE>\r\n"; log += "<SIGNATURE>" + check.ConSol.LicenserName + "</SIGNATURE>\r\n"; } catch { return(null); } log += "</SUMMARYSHEET>\r\n"; return(log); }
public static extern int PowerPolicyNotify(PowerMode powerMode, int flags);
public SatelliteChannel(int lnbIndex, uint uFrequency, SpectrumInversion eInversion, uint uSymbolRate, PowerMode ePower, Viterbi eViterbi) : this(lnbIndex, uFrequency, eInversion, uSymbolRate, ePower, eViterbi, false) { }
private void InitParams() { // TODO: ParamClear breaks pre-connect params. // ParamClear was orginally intended to reset the parameter table // after a firmware update, removing parameters that no longer exist // in the new firmware. Deprioritize post-upgrade behavior for now. // --Harry Tsai 2009 Jun 26 //ParamClear(); // It's okay if this doesn't get set to anything other than NONE; // since the user doesn't need to set the region, the connection // shouldn't fail just because the region is unknown. Reader.Region region = Reader.Region.UNSPEC; String regionName = GetField("regionName", "params").ToUpper(); if (regionName.Equals("US")) region = Reader.Region.NA; else if (regionName.Equals("KR")) { String regionVersion = (string)GetField("region_version", "params"); if (regionVersion.Equals("1") || regionVersion.Equals("")) region = Reader.Region.KR; else if (regionVersion.Equals("2")) region = Reader.Region.KR2; } else if (regionName.Equals("JP")) region = Reader.Region.JP; else if (regionName.Equals("AU")) region = Reader.Region.AU; else if (regionName.Equals("NZ")) region = Reader.Region.NZ; else if (regionName.Equals("CN")) region = Reader.Region.PRC; else if (regionName.Equals("IN")) region = Reader.Region.IN; else if (regionName.Equals("EU")) { String regionVersion = (string) GetField("region_version", "params"); if (regionVersion.Equals("1") || regionVersion.Equals("")) region = Reader.Region.EU; else if (regionVersion.Equals("2")) region = Reader.Region.EU2; else if (regionVersion.Equals("3")) region = Reader.Region.EU3; } ParamAdd(new Setting("/reader/region/supportedRegions", typeof(Region[]), new Region[] { region }, false)); ParamAdd(new Setting("/reader/region/id", typeof(Region), region, false, delegate(Object val) { return val; },null)); ParamAdd(new Setting("/reader/antenna/portList", typeof(int[]), null, false, delegate(Object val) { val = _antennaPorts; return val; }, delegate(Object val) { throw new ArgumentException("Antenna PortList is a Read Only Param"); })); ParamAdd(new Setting("/reader/antenna/connectedPortList", typeof(int[]), null, false, delegate(Object val) { String portList = ""; try { portList = GetField("reader_connected_antennas", "params"); } catch (FeatureNotSupportedException) { if ("Astra" == _model) { portList = "1"; } } String[] ports = portList.Split(' '); List<int> list = new List<int>(); for (int i = 0; i < ports.Length; i++) { if (!ports[i].StartsWith("X")) { try { int value = Convert.ToInt32(ports[i]); list.Add(value); } catch (FormatException) { } } } return list.ToArray(); }, null)); ParamAdd(new Setting("/reader/gen2/q", typeof(Gen2.Q), null, true, delegate(Object val) { int initq = int.Parse(GetField("gen2InitQ", "params")); int minq = int.Parse(GetField("gen2MinQ", "params")); int maxq = int.Parse(GetField("gen2MaxQ", "params")); if ((minq == initq) && (initq == maxq) ) { if (initq >= 0) { return new Gen2.StaticQ((byte)initq); } else { return new Gen2.DynamicQ(); } } else return new Gen2.DynamicQ(); }, delegate(Object val) { if (val is Gen2.StaticQ) { Gen2.StaticQ q = (Gen2.StaticQ) val; if (q.InitialQ < 0 || q.InitialQ > 15) { throw new ArgumentOutOfRangeException("Value of /reader/gen2/q is out of range. Should be between 0 to 15"); } string qval = q.InitialQ.ToString("D"); CmdSetParam("gen2InitQ", qval); CmdSetParam("gen2MinQ", qval); CmdSetParam("gen2MaxQ", qval); } else { CmdSetParam("gen2MinQ", "2"); CmdSetParam("gen2MaxQ", "6"); } int initq = int.Parse(GetField("gen2InitQ", "params")); int minq = int.Parse(GetField("gen2MinQ", "params")); int maxq = int.Parse(GetField("gen2MaxQ", "params")); if ((minq == initq) && (initq == maxq)) return new Gen2.StaticQ((byte) initq); else return new Gen2.DynamicQ(); })); ParamAdd(new Setting("/reader/gen2/session", typeof(Gen2.Session), null, true, delegate(Object val) { string rsp = GetField("gen2Session", "params"); int s = int.Parse(rsp); switch (s) { // -1 is Astra's way of saying "Use the module's value." // That value is dependent on the user mode, so check it. case -1: int mode = int.Parse(GetField("userMode", "params")); if (mode == 3) // portal mode return Gen2.Session.S1; else return Gen2.Session.S0; case 0: return Gen2.Session.S0; case 1: return Gen2.Session.S1; case 2: return Gen2.Session.S2; case 3: return Gen2.Session.S3; } throw new ReaderParseException("Unknown Gen2 session value " + s.ToString()); }, delegate(Object val) { SetField("params.gen2Session", (int) val); return val; })); ParamAdd(new Setting("/reader/gen2/target", typeof(Gen2.Target), null, true, delegate(Object val) { string rsp = GetField("gen2Target", "params"); int rval = int.Parse(rsp); Gen2.Target tgt; switch (rval) { case 0: tgt = Gen2.Target.AB; break; case 1: tgt = Gen2.Target.BA; break; case -1: case 2: tgt = Gen2.Target.A; break; case 3: tgt = Gen2.Target.B; break; default: throw new ReaderParseException("Unrecognized Gen2 target: " + rval.ToString()); } return tgt; }, delegate(Object val) { Gen2.Target tgt = (Gen2.Target) val; int tnum; switch (tgt) { case Gen2.Target.AB: tnum = 0; break; case Gen2.Target.BA: tnum = 1; break; case Gen2.Target.A: tnum = 2; break; case Gen2.Target.B: tnum = 3; break; default: throw new ArgumentException("Unrecognized Gen2.Target " + val.ToString()); } CmdSetParam("gen2Target", String.Format("{0:D}", tnum)); return tgt; })); ParamAdd(new Setting("/reader/gpio/inputList", typeof(int[]), _gpiList, false)); ParamAdd(new Setting("/reader/gpio/outputList", typeof(int[]), _gpoList, false)); ParamAdd(new Setting("/reader/version/model", typeof(string), _model, false)); SettingFilter powerSetFilter = delegate(Object val) { int power = (int) val; if (power < _rfPowerMin) { throw new ArgumentException(String.Format("Requested power ({0:D}) too low (RFPowerMin={1:D}cdBm)", power, _rfPowerMin)); } if (power > _rfPowerMax) { throw new ArgumentException(String.Format("Requested power ({0:D}) too high (RFPowerMax={1:D}cdBm)", power, _rfPowerMax)); } SetField("saved_settings.tx_power", power); _txPower = power; return power; }; ParamAdd(new Setting("/reader/radio/readPower", typeof(int), _txPower, true, null, powerSetFilter)); ParamAdd(new Setting("/reader/read/plan", typeof(ReadPlan), new SimpleReadPlan(), true, null, delegate(Object val) { if ((val is SimpleReadPlan) || (val is MultiReadPlan)) { return val; } else { throw new ArgumentException("Unsupported /reader/read/plan type: " + val.GetType().ToString() + "."); } })); ParamAdd(new Setting("/reader/radio/powerMax", typeof(int), _rfPowerMax, false)); ParamAdd(new Setting("/reader/radio/powerMin", typeof(int), _rfPowerMin, false)); ParamAdd(new Setting("/reader/version/serial", typeof(string), _serialNumber, false)); ParamAdd(new Setting("/reader/version/software", typeof(string), _softwareVersion, false)); ParamAdd(new Setting("/reader/version/supportedProtocols", typeof(TagProtocol[]), _supportedProtocols, false)); ParamAdd(new Setting("/reader/tagop/antenna", typeof(int), GetFirstConnectedAntenna(), true, null, delegate(Object val) { return ValidateAntenna((int) val); })); ParamAdd(new Setting("/reader/tagop/protocol", typeof(TagProtocol), TagProtocol.GEN2, true, null, delegate(Object val) { return ValidateProtocol((TagProtocol) val); })); ParamAdd(new Setting("/reader/radio/writePower", typeof(int), _txPower, true, null, powerSetFilter)); ParamAdd(new Setting("/reader/powerMode", typeof(PowerMode), null, true, delegate(Object val) { if (_socket.Connected) return Convert.ToInt32(GetField("powerMode","params")); else return val; }, delegate(Object val) { if (_socket.Connected) CmdSetPowerMode((PowerMode)val); powerMode = (PowerMode)val; return powerMode; })); ParamAdd(new Setting("/reader/hostname", typeof(string), null, true, delegate(Object val) { string hostName = null; try { hostName = GetField("hostname", "saved_settings"); } catch (Exception ex) { if (ex is FeatureNotSupportedException) { hostName = string.Empty; } } return hostName; }, delegate(Object val) { if (!val.Equals(_hostname)) { SetField("saved_settings.hostname", val); _hostname = val.ToString(); return _hostname; } else { return _hostname; } })); ParamAdd(new Setting("/reader/currentTime", typeof(DateTime), null, false, delegate(Object val) { return Convert.ToDateTime( GetField("current_time", "settings")); }, null)); ParamAdd(new Setting("/reader/antennaMode", typeof(int), null, false, delegate(Object val) { return Convert.ToInt32( GetField("antenna_mode", "saved_settings")); }, null)); ParamAdd(new Setting("/reader/antenna/checkPort", typeof(bool), null, true, delegate(Object val) { return ConvertValueToBool(GetField("antenna_safety", "params")); }, delegate(Object val) { SetParamBoolValue("antenna_safety", (bool)val); return val; })); if (!(_model.Equals("Astra"))) { ParamAdd(new Setting("/reader/version/hardware", typeof(string), null, false, delegate(Object val) { val = GetField("reader_hwverdata", "params"); return val; }, null)); ParamAdd(new Setting("/reader/radio/temperature", typeof(int), null, false, delegate(Object val) { val = Convert.ToInt32(GetField("reader_temperature", "params")); return val; }, null)); ParamAdd(new Setting("/reader/radio/enableSJC", typeof(bool), false, false, delegate(Object val) { return ConvertValueToBool(GetField("enableSJC", "params")); }, null)); ParamAdd(new Setting("/reader/gen2/BLF", typeof(Gen2.LinkFrequency), null, true, delegate(Object val) { int frequency = Convert.ToInt16(GetField("gen2BLF", "params")); frequency = (frequency == -1) ? frequency : gen2BLFIntToValue(frequency); return Enum.Parse(typeof(Gen2.LinkFrequency), frequency.ToString(), true); }, delegate(Object val) { int blf = gen2BLFObjectToInt(val); if (_model.Equals("Mercury6") && (blf == 2) || (blf == 3)) { throw new ReaderException("Link Frequency not supported on M6"); } SetField("params.gen2BLF", blf); return val; } , false) ); ParamAdd(new Setting("/reader/iso180006b/BLF", typeof(Iso180006b.LinkFrequency), Iso180006b.LinkFrequency.LINK160KHZ, true, delegate(Object val) { int frequency = Convert.ToInt16(GetField("i186bBLF", "params")); frequency = (frequency == -1) ? iso18000BBLFIntToValue(0) : iso18000BBLFIntToValue(frequency); return Enum.Parse(typeof(Iso180006b.LinkFrequency), frequency.ToString(), true); }, delegate(Object val) { SetField("params.i186bBLF", iso18000BBLFObjectToInt(val)); return val; }, false)); ParamAdd(new Setting("/reader/gen2/tagEncoding", typeof(Gen2.TagEncoding), null, true, delegate(Object val) { return Enum.Parse(typeof(Gen2.TagEncoding), GetField("gen2TagEncoding", "params"), true); }, delegate(object val) { SetField("params.gen2TagEncoding", (int)(val)); return val; }, false)); ParamAdd(new Setting("/reader/gen2/tari", typeof(Gen2.Tari), null, true, delegate(Object val) { return Enum.Parse(typeof(Gen2.Tari), GetField("gen2Tari", "params"), true); }, delegate(object val) { SetField("params.gen2Tari", (int)(val)); return val; }, false)); } ParamAdd(new Setting("/reader/description", typeof(string), null, true, delegate(Object val) { string readerDesc = null; try { readerDesc = GetField("reader_description", "params"); } catch(Exception ex) { if (ex is FeatureNotSupportedException) { readerDesc = string.Empty; } } return readerDesc; }, delegate(Object val) { SetField("params.reader_description", val); return val; }, false)); ParamAdd(new Setting("/reader/radio/portReadPowerList", typeof(int[][]), null, true, delegate(Object val) { return GetPortPowerList(val,"read"); }, delegate(Object val) { Query(SetPowerList(val, "read")); return val; }, false)); ParamAdd(new Setting("/reader/radio/portWritePowerList", typeof(int[][]), null, true, delegate(Object val) { return GetPortPowerList(val,"write"); }, delegate(Object val) { Query(SetPowerList(val, "write")); return val; }, false)); ParamAdd(new Setting("/reader/tagReadData/uniqueByAntenna", typeof(bool),false,true, delegate(Object val) { return val; }, delegate(Object val) { return val; }, false)); ParamAdd(new Setting("/reader/tagReadData/uniqueByData", typeof(bool), false, true, delegate(Object val) { return val; }, delegate(Object val) { return val; }, false)); ParamAdd(new Setting("/reader/tagReadData/recordHighestRssi", typeof(bool), false, true, delegate(Object val) { return val; }, delegate(Object val) { return val; }, false)); ParamAdd(new Setting("/reader/tagReadData/enableReadFilter", typeof(bool), true, false, delegate(Object val) { return true; }, null)); ParamAdd(new Setting("/reader/tagReadData/uniqueByProtocol", typeof(bool), true, false, delegate(Object val) { return true; }, null)); ParamAdd(new Setting("/reader/licenseKey", typeof(ICollection<byte>), null, true, null, delegate(Object val) { string[] key = (ByteFormat.ToHex((byte[])val).Split('x')); SetField("params.reader_licenseKey", key[1].ToString()); string res = GetField("reader_licenseKey", "params"); if(res.StartsWith("0000")) { return null; } throw new ReaderException(res.ToString()); })); }
public async Task SetPowerMode(PowerMode newMode) { WriteByte((byte)BNO055Register.BNO055_PWR_MODE_ADDR, (byte)newMode); await Task.Delay(30); }
public string CurrentMode() => PowerMode.CurrentMode();
/// <summary> /// Set the current power mode of the device. /// </summary> /// <param name="powermode">the mode to set</param> public void CmdSetPowerMode(PowerMode powermode) { if (powerMode != powermode) { SetField("params.powerMode", powermode.GetHashCode()); powerMode = powermode; } }
public void ChangeMode(bool UpDown) => PowerMode.ChangeMode(UpDown);
/// <summary> /// Puts the sensor into initial state. /// </summary> /// <param name="power">Power consumption/resolution mode.</param> public void Init(PowerMode power = PowerMode.Standard) { powerMode = (byte)power; ReadCalibrationData(); }
/// <summary> /// Set the output power of the VisiLED controller. /// </summary> /// <param name="channel">The channel to apply the new power setting too.</param> /// <param name="mode">The power mode to set the power for (normal or strobe).</param> /// <param name="power">The % power to apply to the channel (0-100).</param> public void SetPower(Channel channel, PowerMode mode, double power) { CurrentConnection?.SetPower(channel, mode, power); }
/// <summary> /// Wake up procedure /// </summary> private void WakeUp() { switch (this.powerMode) { case PowerMode.Normal: // nothing break; case PowerMode.PowerDown: // TODO : wake up needed or nothing ? // this.commLayer.WakeUp(); break; case PowerMode.LowVbat: // PN532 Application Note C106 pag. 23 // wake up needed this.commLayer.WakeUp(); // SAM Configuration in normal mode command is needed (pn532um.pdf, pag. 13) byte[] cmd = { PN532_SAM_CONFIGURATION, (byte)SamMode.NormalMode, 0x00, 0x00 }; // send cmd and check acknowledge if (this.SendNormalFrame(cmd)) { byte[] response = this.ReadNormalFrame(); } break; default: break; } this.powerMode = PowerMode.Normal; }
/// <summary> /// Set MAX7219 Power /// </summary> /// <param name="mode">Mode</param> public void SetPower(PowerMode mode) { led.Write(new byte[] { MAX_POWER_REG_ADDR, (byte)mode }); }