public static TriggerOptions fromBytes(this TriggerOptions res, byte[] value) { res = TriggerOptions.NONE; if (value == null || value.Length < 1) { return(res); } if ((value[0] & Scsm_MMS.TrgOpsDataChange) == Scsm_MMS.TrgOpsDataChange) { res |= TriggerOptions.DATA_CHANGED; } if ((value[0] & Scsm_MMS.TrgOpsQualChange) == Scsm_MMS.TrgOpsQualChange) { res |= TriggerOptions.QUALITY_CHANGED; } if ((value[0] & Scsm_MMS.TrgOpsDataActual) == Scsm_MMS.TrgOpsDataActual) { res |= TriggerOptions.DATA_UPDATE; } if ((value[0] & Scsm_MMS.TrgOpsIntegrity) == Scsm_MMS.TrgOpsIntegrity) { res |= TriggerOptions.INTEGRITY; } if ((value[0] & Scsm_MMS.TrgOpsGI) == Scsm_MMS.TrgOpsGI) { res |= TriggerOptions.GI; } return(res); }
/// <summary> /// Initializes a new instance of this class. /// </summary> public ActionTriggers() { _t = new ITriggers[(int)TriggerType.Count]; scopes_ = new TriggerScopes(); funcs_ = new TriggerFuncs(); options_ = new TriggerOptions(); }
/// <summary> /// </summary> /// <param name="triggerOptions"> /// </param> /// <param name="condition"> /// </param> public Action(TriggerOptions triggerOptions, Condition condition = null) { this.trigger = triggerOptions.trigger; this._triggerParameter = triggerOptions.parameter; this._nextActiveAction = this; this._condition = condition; }
public static byte[] toBytes(this TriggerOptions inp) { byte[] res = new byte[1]; if ((inp & TriggerOptions.DATA_CHANGED) == TriggerOptions.DATA_CHANGED) { res[0] |= Scsm_MMS.TrgOpsDataChange; } if ((inp & TriggerOptions.QUALITY_CHANGED) == TriggerOptions.QUALITY_CHANGED) { res[0] |= Scsm_MMS.TrgOpsQualChange; } if ((inp & TriggerOptions.DATA_UPDATE) == TriggerOptions.DATA_UPDATE) { res[0] |= Scsm_MMS.TrgOpsDataActual; } if ((inp & TriggerOptions.INTEGRITY) == TriggerOptions.INTEGRITY) { res[0] |= Scsm_MMS.TrgOpsIntegrity; } if ((inp & TriggerOptions.GI) == TriggerOptions.GI) { res[0] |= Scsm_MMS.TrgOpsGI; } return(res); }
/// <summary> /// Extension for start, load (charge) and release a trigger based on a given observable source. /// </summary> /// <param name="source">The main source for the trigger</param> /// <param name="triggerStartSelector">Pass the source itself to the lambda -> OnNext opens a new trigger charging</param> /// <param name="triggerCancelSelector">Pass the trigger observed data since started to the lambda -> OnNext cancels (all) the previous started charges</param> /// <param name="triggerReleaseSelector">Pass the source itself to the lambda -> OnNext release the charged trigger</param> /// <param name="scheduler">An scheduler where execute this action</param> /// <param name="cancelPreviousOnTriggerStart">if true, closes (all) the previous started triggers based on triggerStartSelect.OnNext passing the trigger observed data since started</param> /// <returns>Returns an Unit in the sequence each time the trigger is released</returns> public static IObservable <Unit> Trigger <T, TDontCare1, TDontCare2>(this IObservable <T> source, Func <T, bool> triggerStartSelector, Func <IObservable <T>, IObservable <TDontCare1> > triggerCancelSelector, Func <IObservable <T>, IObservable <TDontCare2> > triggerReleaseSelector, IScheduler scheduler, TriggerOptions triggerOptions) { source.EnsureNotNull("source"); triggerCancelSelector.EnsureNotNull("triggerCancelSelector"); triggerStartSelector.EnsureNotNull("triggerStartSelector"); triggerReleaseSelector.EnsureNotNull("triggerReleaseSelector"); scheduler.EnsureNotNull("scheduler"); return(Observable.Create <Unit>(o => { return scheduler.Schedule( 0, (s, st) => { var isStarted = 1; // 0: true __ 1: false var refCountedSource = source.Publish().RefCount(); return refCountedSource .Window(refCountedSource.Where(el => triggerStartSelector(el) // No start if it is already started && (triggerOptions == TriggerOptions.DiscardTriggerIfAlreadyStarted ? Interlocked.Exchange(ref isStarted, 0) == 0 : true)), t => triggerReleaseSelector(refCountedSource.Merge(Observable.Return(t)))) .Subscribe(trigger => { var triggerDisposable = new CompositeDisposable(); triggerDisposable.Add(trigger .Subscribe(_ => { }, () => { Interlocked.Exchange(ref isStarted, 1); o.OnNext(Unit.Default); triggerDisposable.Dispose(); })); triggerDisposable.Add(triggerCancelSelector(trigger) .FirstOrDefaultAsync() .Subscribe(_ => { Interlocked.Exchange(ref isStarted, 1); triggerDisposable.Dispose(); })); if (triggerOptions == TriggerOptions.CancelPreviousOnTriggerStart) { triggerDisposable.Add(trigger.Where(triggerStartSelector) .Skip(1) .Subscribe(_ => { triggerDisposable.Dispose(); })); } }); }); })); }
} /* include reason code in log */ public LCB(string name, string reference, bool logEna, string dataSet, TriggerOptions trgOptions, uint intgPd, bool reasonCode) { LCBName = name; LCBRef = reference; LCBLogEna = logEna; LCBDatSet = dataSet; LCBtrgOptions = trgOptions; LCBintgPd = intgPd; LCBreasonCode = reasonCode; }
/// <summary> /// Initializes a new instance of the class. /// </summary> public Trigger(TriggerOptions triggerOptions, DataSource dataSource) { DataSource = dataSource ?? throw new ArgumentNullException(nameof(dataSource)); Options = triggerOptions ?? throw new ArgumentNullException(nameof(triggerOptions)); CnlNums = new HashSet <int>(Options.CnlNums); DeviceNums = new HashSet <int>(Options.DeviceNums); Command = dataSource.CreateCommand(); Command.CommandText = triggerOptions.Query; InitParams(); }
public IEnumerable <IEnumerable <TriggerContextDescriptor> > Discover(TriggerOptions options, TriggerContextTracker tracker, ILogger logger) { var changes = tracker.DiscoveredChanges ?? throw new InvalidOperationException("Trigger discovery process has not yet started. Please ensure that TriggerSession.DiscoverChanges() or TriggerSession.RaiseBeforeSaveTriggers() has been called"); if (logger.IsEnabled(LogLevel.Debug)) { _changesDetected(logger, changes.Count(), _name, null); } return(Enumerable.Repeat(changes, 1)); }
public RCB(string rcbName, string rcbRef, ReportOptions rcbrptOptions, TriggerOptions rcbtrgOptions, string rcbBuffered, string rcbrptId, string rcbdatSet, uint rcbconfRev, uint rcbbufTime, uint rcbintgPd) { RCBName = rcbName; RCBRef = rcbRef; RCBrptOptions = rcbrptOptions; RCBtrgOptions = rcbtrgOptions; RCBbuffered = rcbBuffered; RCBrptId = rcbrptId; RCBdatSet = rcbdatSet; RCBconfRev = rcbconfRev; RCBbufTime = rcbbufTime; RCBintgPd = rcbintgPd; }
public static IObservable <Unit> Trigger <T, TDontCare1>( this IObservable <T> source, Func <T, bool> triggerStartSelector, Func <IObservable <T>, IObservable <TDontCare1> > triggerCancelSelector, Func <TimeSpan> releaseTimeSelector, IScheduler scheduler, TriggerOptions triggerOptions) { releaseTimeSelector.EnsureNotNull("releaseTimeSelector"); scheduler.EnsureNotNull("scheduler"); return(source .Trigger( triggerStartSelector, triggerCancelSelector, s => s.Throttle(releaseTimeSelector(), scheduler), scheduler, triggerOptions )); }
/// <summary> /// Enables the blink algorithm by sending the Trigger command. /// </summary> /// <param name="touchSensor">TRUE if the touch sensor for disabling the blink algorithm is enabled.</param> /// <param name="timeout">TRUE if the timeout of the blink algorithm is enabled.</param> /// <param name="auxOutput">TRUE if the auxiliary output signal is enabled.</param> /// <returns>TRUE on success.</returns> public bool Trigger(bool touchSensor, bool timeout, bool auxOutput) { TriggerOptions flags = TriggerOptions.None; if (touchSensor) { flags |= TriggerOptions.TouchSensor; } if (timeout) { flags |= TriggerOptions.Timeout; } if (auxOutput) { flags |= TriggerOptions.AuxOutput; } return(Trigger(flags)); }
public IEnumerable <IEnumerable <TriggerContextDescriptor> > Discover(TriggerOptions options, TriggerContextTracker tracker, ILogger logger) { var maxCascadingCycles = options.MaxCascadeCycles; _discoveryStarted(logger, _name, maxCascadingCycles, null); var iteration = 0; while (true) { if (iteration > maxCascadingCycles) { throw new InvalidOperationException("MaxCascadingCycle was reached"); } var changes = tracker.DiscoverChanges(); // In case someone made a call to TriggerSession.DetectChanges, prior to calling RaiseBeforeSaveTriggers, we want to make sure that we include that discovery result in the first iteration if (iteration == 0 && !_skipDetectedChanges) { changes = tracker.DiscoveredChanges !; } if (changes.Any()) { if (logger.IsEnabled(LogLevel.Debug)) { changes = changes.ToList(); _changesDetected(logger, changes.Count(), _name, iteration, maxCascadingCycles, null); } yield return(changes); } else { break; } iteration++; } }
/// <summary> /// Enables the blink algorithm by sending the Trigger command. /// </summary> /// <param name="flags">Options to be used by the Trigger command.</param> /// <returns>TRUE on success.</returns> public bool Trigger(TriggerOptions flags = DefaultTriggerOptions) { isValidCall(); return(sendReport(Command.Trigger, (byte)flags)); }
/// <summary> /// Save current trigger to file /// </summary> public void SaveTrigger() { if (!Directory.Exists(Bot.username + "/triggers/")) { Directory.CreateDirectory(Bot.username + "/triggers/"); } if (Options != null) { TriggerOptions options = new TriggerOptions { Delay = Options.Delay, Probability = Options.Probability, Timeout = Options.Timeout, Ignore = Options.Ignore, User = Options.User, Rooms = Options.Rooms, Command = Options.Command, Matches = Options.Matches, Responses = Options.Responses, ApiKey = Options.ApiKey }; string json = JsonConvert.SerializeObject(options, Formatting.Indented); File.WriteAllText(Bot.username + "/triggers/" + Name + ".json", json); } else if (Options == null) { TriggerOptions options = new TriggerOptions(); string json = JsonConvert.SerializeObject(options, Formatting.Indented); File.WriteAllText(Bot.username + "/triggers/" + Name + ".json", json); } }
public BaseTrigger(TriggerType type, string name, TriggerOptions options) { Type = type; Name = name; Options = options; }
public TPriceTrigger(string symbol, ComparisonOperator comparisonOperator, decimal price, TriggerOptions options = null) { this.Symbol = symbol; this.ComparisonOperator = comparisonOperator; this.Price = price; this.Options = options; }
/// <summary> /// Initializes a new instance of the class. /// </summary> public ArcDataTrigger(TriggerOptions triggerOptions, DataSource dataSource) : base(triggerOptions, dataSource) { ArcDataTriggerOptions = (ArcDataTriggerOptions)triggerOptions; }
public DoormatTrigger(TriggerType type, string name, TriggerOptions options) : base(type, name, options) { }
/** * \brief create a new report control block (RCB) * * Create a new report control block (RCB) and add it to the given logical node (LN). * * \param name name of the RCB relative to the parent LN * \param parent the parent LN. * \param rptId of the report. If NULL the default report ID (object reference) is used. * \param isBuffered true for a buffered RCB - false for unbuffered RCB * \param dataSetName name (object reference) of the default data set or NULL if no data * is set by default * \param confRef the configuration revision * \param trgOps the trigger options supported by this RCB (bit set) * \param options the inclusion options. Specifies what elements are included in a report (bit set) * \param bufTm the buffering time of the RCB in milliseconds (time between the first event and the preparation of the report). * \param intgPd integrity period in milliseconds * * \return the new RCB instance. */ public ReportControlBlock(string name, LogicalNode parent, string rptId, bool isBuffered, string dataSetName, uint confRef, TriggerOptions trgOps, ReportOptions options, uint bufTm, uint intgPd) { self = ReportControlBlock_create(name, parent.GetLibraryObject(), rptId, isBuffered, dataSetName, confRef, (byte)trgOps, (byte)options, bufTm, intgPd); }
public Report(string rptID, Connection _con, IntPtr _conPtr, Handler _handler, TriggerOptions _trg, uint _poll) { this._handler = _handler; int _err = 0; _rpt = ClientReportControlBlock_create(rptID); _err = 0; IedConnection_getRCBValues(_conPtr, out _err, rptID, _rpt); if (_err != 0) { Console.WriteLine(((IedError)_err).ToString()); return; } string _repID = Marshal.PtrToStringAnsi(ClientReportControlBlock_getRptId(_rpt)); IedConnection_installReportHandler(_conPtr, rptID, _repID, ReportHandler, IntPtr.Zero); ClientReportControlBlock_setTrgOps(_rpt, (int)_trg); flagTrgOps = true; if ((_trg & TriggerOptions.INTEGRITY) == TriggerOptions.INTEGRITY) { ClientReportControlBlock_setIntgPd(_rpt, _poll); flagIntgPd = true; } ClientReportControlBlock_setOptFlds(_rpt, (int)(ReportOptions.DATA_REFERENCE | ReportOptions.REASON_FOR_INCLUSION)); flagOptFlds = true; ClientReportControlBlock_setRptEna(_rpt, true); flagRptEna = true; _err = 0; IedConnection_setRCBValues(_conPtr, out _err, _rpt, GetMask(), true); resetFlags(); Console.WriteLine(((IedError)_err).ToString()); }
public LinkNameTrigger(TriggerType type, string name, TriggerOptions options) : base(type, name, options) { }
/// <summary> /// Creates a tree node corresponding to the trigger. /// </summary> private TreeNode CreateTriggerNode(TriggerOptions triggerOptions) { return(TreeViewUtils.CreateNode(triggerOptions, ChooseImageKey(triggerOptions))); }
public void Subscribe(string rptID, Report.Handler _hand, TriggerOptions _trg, uint poll) { new Report(rptID, this._con, _con._con, _hand, _trg, poll); }
public AcceptChatInviteTrigger(TriggerType type, string name, TriggerOptions options) : base(type, name, options) { }
private void buttonOK_Click(object sender, EventArgs e) { // test //RCBpar.self.GI = false; //RCBpar.self.RptEna = true; RCBpar.sendRptID = checkBoxRptID_send.Checked; if (RCBpar.sendRptID) { RCBpar.self.RptID = textBoxRptID.Text; } RCBpar.sendDatSet = checkBoxDatSet_send.Checked; if (RCBpar.sendDatSet) { RCBpar.self.DatSet = comboBoxDatSet.Text; } RCBpar.sendOptFlds = checkBoxOptFlds_send.Checked; if (RCBpar.sendOptFlds) { ReportOptions ro = ReportOptions.NONE; if (checkBoxOptFlds_SeqNum.Checked) { ro |= ReportOptions.SEQ_NUM; } if (checkBoxOptFlds_TimeStamp.Checked) { ro |= ReportOptions.TIME_STAMP; } if (checkBoxOptFlds_ReasonForInclusion.Checked) { ro |= ReportOptions.REASON_FOR_INCLUSION; } if (checkBoxOptFlds_DataSet.Checked) { ro |= ReportOptions.DATA_SET; } if (checkBoxOptFlds_DataReference.Checked) { ro |= ReportOptions.DATA_REFERENCE; } if (checkBoxOptFlds_BufferOverflow.Checked) { ro |= ReportOptions.BUFFER_OVERFLOW; } if (checkBoxOptFlds_EntryID.Checked) { ro |= ReportOptions.ENTRY_ID; } if (checkBoxOptFlds_ConfRev.Checked) { ro |= ReportOptions.CONF_REV; } RCBpar.self.OptFlds = ro; } RCBpar.sendBufTm = checkBoxBufTm_send.Checked; if (RCBpar.sendBufTm) { try { RCBpar.self.BufTm = uint.Parse(textBoxBufTm.Text); } catch { } } RCBpar.sendTrgOps = checkBoxTrgOps_send.Checked; if (RCBpar.sendTrgOps) { TriggerOptions to = TriggerOptions.NONE; if (checkBoxTrgOps_DataChange.Checked) { to |= TriggerOptions.DATA_CHANGED; } if (checkBoxTrgOps_QualityChange.Checked) { to |= TriggerOptions.QUALITY_CHANGED; } if (checkBoxTrgOps_DataUpdate.Checked) { to |= TriggerOptions.DATA_UPDATE; } if (checkBoxTrgOps_Integrity.Checked) { to |= TriggerOptions.INTEGRITY; } if (checkBoxTrgOps_GI.Checked) { to |= TriggerOptions.GI; } RCBpar.self.TrgOps = to; } RCBpar.sendIntgPd = checkBoxIntgPd_send.Checked; if (RCBpar.sendIntgPd) { try { RCBpar.self.IntgPd = uint.Parse(textBoxIntgPd.Text); } catch { } } RCBpar.sendRptEna = checkBoxRptEna_send.Checked; if (RCBpar.sendRptEna) { RCBpar.self.RptEna = checkBoxRptEna.Checked; } RCBpar.sendGI = checkBoxGI_send.Checked; if (RCBpar.sendGI) { RCBpar.self.GI = checkBoxGI.Checked; } RCBpar.sendResv = checkBoxResv_send.Checked; if (RCBpar.sendResv) { RCBpar.self.Resv = checkBoxResv.Checked; } RCBpar.sendPurgeBuf = checkBoxPurgeBuf_send.Checked; if (RCBpar.sendPurgeBuf) { RCBpar.self.PurgeBuf = checkBoxPurgeBuf.Checked; } RCBpar.sendEntryID = checkBoxEntryID_send.Checked; if (RCBpar.sendEntryID) { RCBpar.self.EntryID = textBoxEntryID.Text; } RCBpar.sendResvTms = checkBoxResvTms_send.Checked; if (RCBpar.sendResvTms) { try { RCBpar.self.ResvTms = uint.Parse(textBoxResvTms.Text); } catch { } } }
public KickTrigger(TriggerType type, string name, TriggerOptions options) : base(type, name, options) { }
public LeaveChatTrigger(TriggerType type, string name, TriggerOptions options) : base(type, name, options) { }
/// <summary> /// Sets the trigger options of the RCB. /// </summary> /// <param name='trgOps'> /// trigger options /// </param> public void SetTrgOps(TriggerOptions trgOps) { ClientReportControlBlock_setTrgOps(self, (int)trgOps); flagTrgOps = true; }
public BaseTrigger(TriggerType type, string name) { Type = type; Name = name; Options = new TriggerOptions(); }
/// <summary> /// Initializes a new instance of the class. /// </summary> public CurDataTrigger(TriggerOptions triggerOptions, DataSource dataSource) : base(triggerOptions, dataSource) { CurDataTriggerOptions = (CurDataTriggerOptions)triggerOptions; }
public void Subscribe(string rptID, Report.Handler _hand, TriggerOptions _trg) { Subscribe(rptID, _hand, _trg, 5000); }
public UnmoderateChatTrigger(TriggerType type, string name, TriggerOptions options) : base(type, name, options) { }
public ChatReplyTrigger(TriggerType type, string name, TriggerOptions options) : base(type, name, options) { }
public DataAttribute(string name, ModelNode parent, DataAttributeType type, FunctionalConstraint fc, TriggerOptions trgOps, int arrayElements, UInt32 sAddr) { self = DataAttribute_create(name, parent.self, (int)type, (int)fc, (byte)trgOps, arrayElements, sAddr); }
/// <summary> /// Initializes a new instance of the class. /// </summary> public EventTrigger(TriggerOptions triggerOptions, DataSource dataSource) : base(triggerOptions, dataSource) { EventTriggerOptions = (EventTriggerOptions)triggerOptions; }