/// <summary> /// Sets the lights given by the bitmask based on the action parameter (SetAction) /// </summary> /// <param name="bitmask_"></param> /// <param name="action_"></param> /// <returns></returns> /// <remarks> /// Note: Does not affect pins 0 and 15 /// </remarks> private ushort Set(ushort bitmask_, SetAction action_) { // Store heartbeat mask byte hi = (byte)((_state >> 8) & 0x80); byte lo = (byte)(_state & 0x01); lock (_mutex) { // Apply bitmask to state switch (action_) { case SetAction.Disable: _state &= (ushort)(~bitmask_); break; case SetAction.Enable: _state |= bitmask_; break; case SetAction.Force: _state = bitmask_; break; default: break; } } return(TransmitStateUsingHiLoHeartbeatMask(hi, lo)); }
public bool UseWhen(PropertyInfo info, string tableValue) { var innerType = Nullable.GetUnderlyingType(info.PropertyType); return(info.PropertyType.IsGenericType && info.PropertyType.GetGenericTypeDefinition() == typeof(Nullable <>) && SetAction.ImplementsIConvertible(innerType)); }
private IEnumerable <IActor <T> > CreateActors <T>(SetAction <T> func) { yield return(new OrderedSyncActor <T>(func)); yield return(new OrderedAsyncActor <T>(func)); //yield return new UnorderedAsyncActor<T>(func); yield return(new PeriodicAsyncActor <T>(func, TimeSpan.FromMilliseconds(20))); yield return(new MostRecentAsyncActor <T>(func)); }
public async Task TestFirstAndLast() { // queue some tasks that take 200ms 100ms apart var firsts = new bool[3]; var lasts = new bool[3]; int spot = 0; SetAction <int> t = (r, tok, f, l) => { firsts[spot] = f; lasts[spot++] = l; }; foreach (var queue in CreateActors(t)) { firsts = new bool[3]; lasts = new bool[3]; spot = 0; Task last = null; //for (var i = 0; i < 3; i++) //{ // last = queue.Push(i); //} last = queue.PushMany(new[] { 1, 2, 3 }); if (last != null) { await last; } Assert.True(firsts[0]); Assert.True(lasts[spot - 1]); if (spot > 1) { Assert.False(firsts[1]); Assert.False(firsts[2]); Assert.False(lasts[0]); Assert.False(lasts[1]); } } }
public IActor <T> Create <T>(ActorType type, SetAction <T> action, TimeSpan?period = null) { switch (type) { case ActorType.MostRecentAsync: return(new MostRecentAsyncActor <T>(action)); case ActorType.OrderedAsync: return(new OrderedAsyncActor <T>(action)); case ActorType.OrderedSync: return(new OrderedSyncActor <T>(action)); case ActorType.PeriodicAsync: return(new PeriodicAsyncActor <T>(action, period.GetValueOrDefault(TimeSpan.FromSeconds(0.1)))); case ActorType.UnorderedAsync: return(new UnorderedAsyncActor <T>(action)); default: throw new NotSupportedException(); } }
public void RunAction(float value) { SetAction?.Invoke(value); }
internal void Perform(IAction iAction) { SetAction setAction = (SetAction)iAction; SetAction newAction = new SetAction(mesh, setAction.EdgeIndex, setAction.EdgeState); if (!undoTree.Do(newAction)) throw new Exception("Invalid move suggested."); if (newAction.Successful == false) throw new Exception("Invalid move suggested."); this.Refresh(); }
public MostRecentAsyncActor(SetAction <T> action) : base((t, c, f, l) => { action.Invoke(t, c, f, l); return(true); }) { }
public OrderedAsyncActor(SetAction <T> action) : base((t, c, f, l) => { action.Invoke(t, c, f, l); return(true); }) { }
public PeriodicAsyncActor(SetAction <T> action, TimeSpan period) : base((t, c, f, l) => { action.Invoke(t, c, f, l); return(true); }, period) { }