public void Add(Trigger trigger, XState to_state, TransitionCallback callback) { XUtils.Assert(!mTransitions.ContainsKey(trigger)); XTransition transition = new XTransition(to_state, callback); mTransitions.Add(trigger, transition); }
public XStateMachine(Trigger never_transition_value) { mCurrentState = null; mLocked = false; mNeverTransitionValue = never_transition_value; mStates = new SortedDictionary <txStateID, XState>(); }
public DeviceStateViewModel(XState deviceState) { State = deviceState; StateClasses = new ObservableCollection<XStateClassViewModel>(); AdditionalStates = new ObservableCollection<XAdditionalState>(); State.StateChanged += new Action(OnStateChanged); OnStateChanged(); }
public DirectionViewModel(XState state) { DirectionState = state; _stateClass = state.StateClass; state.StateChanged += new Action(OnStateChanged); No = state.Direction.No; Name = state.Direction.Name; }
public txStateID CreateState(StateCallback callback) { XUtils.Assert(!mLocked, "Modifying state machine while in use not allowed."); XState state = new XState(callback, mNeverTransitionValue); mStates.Add(state.mStateID, state); return(state.mStateID); }
public ZoneViewModel(XState state) { ZoneState = state; _stateClass = state.StateClass; state.StateChanged += new Action(OnStateChanged); No = state.Zone.No; Name = state.Zone.Name; }
public XLogCfg( string filePath, bool enabled, XFlags flags = (XFlags)((1 << 17) - 1), XState state = (XState)((1 << 7) - 1), string ext = "bx", int rotSizeKb = 500) { LogFilePath = filePath; IsEnabled = enabled; Ext = ext; RotationLogFileKB = rotSizeKb; Flags = flags; State = state; }
public bool ProcessTrigger(Trigger trigger, out XState to_state) { XTransition transition; if (mTransitions.TryGetValue(trigger, out transition)) { to_state = transition.Trigger(); return(true); } to_state = null; return(false); }
public bool Mark(XState s) { switch (s) { case XState.Beamed: return(Interlocked.CompareExchange(ref state, (int)XState.Beamed, (int)XState.Created) == (int)XState.Created); case XState.Processing: return(Interlocked.CompareExchange(ref state, (int)XState.Processing, (int)XState.Received) == (int)XState.Received); case XState.Faulted: { Interlocked.Exchange(ref state, (int)XState.Faulted); return(true); } default: return(false); } }
public void ProcessTrigger(Trigger trigger) { mLocked = true; XState change; if (mCurrentState != null) { bool transition = mCurrentState.ProcessTrigger(trigger, out change); if (transition) { mCurrentState = change; } } mLocked = false; }
public void RemoveState(txStateID state_id, txStateID new_state_if_current) { XUtils.Assert(!mLocked, "Modifying state machine while in use not allowed."); // if that was the current state, prepare to switch states as indicated. // remove all transitions to that state from other states. // remove state. XState next_state = null; if (mCurrentState.mStateID.Equals(state_id)) { XUtils.Assert(!new_state_if_current.Equals(state_id)); if (new_state_if_current.Equals(txStateID.kNone)) { XUtils.Assert(mStates.Count == 1, "can only switch to no current state if removing the last state"); mCurrentState = null; } else { bool found_next = mStates.TryGetValue(new_state_if_current, out next_state); XUtils.Assert(found_next); } } for (int i = 0; i < mStates.Count; ++i) { var state_i = mStates.ElementAt(i); state_i.Value.RemoveTransitionsTo(state_id); } if (next_state != null) { mCurrentState = next_state; } XState state; bool found = mStates.TryGetValue(state_id, out state); XUtils.Assert(found); mStates.Remove(state_id); }
public void SetStartingState(txStateID starting_state) { XUtils.Assert(mCurrentState == null); XUtils.Assert(!starting_state.Equals(txStateID.kNone)); mCurrentState = GetState(starting_state); }
private static Brush GetDynamicXBrush(Guid guid, XState deviceState) { Brush brush = null; if (_dynamicXBrushes.ContainsKey(guid)) { var brushes = _dynamicXBrushes[guid].ContainsKey(deviceState.StateClass) ? _dynamicXBrushes[guid][deviceState.StateClass] : null; brush = brushes != null && brushes.ContainsKey(string.Empty) ? brushes[string.Empty] : null; if (brush == null && _dynamicXBrushes[guid].ContainsKey(XStateClass.No)) { brushes = _dynamicXBrushes[guid][XStateClass.No]; brush = brushes != null && brushes.ContainsKey(string.Empty) ? brushes[string.Empty] : null; } } return brush ?? EmptyBrush; }
public bool IsOn(XFlags f, XState s) => (f & Flags) == f && (s & State) == s && IsEnabled;
public ZoneTooltipViewModel(XZone zone) { State = zone.State; Zone = zone; }
public TagZone(int tagId, XState state) { TagId = tagId; ZoneState = state; state.StateChanged += new System.Action(OnStateChanged); }
public XTransition(XState to_state, TransitionCallback callback) { mToState = to_state; mTransitionCallback = callback; }
public TagDirection(int tagId, XState state) { TagId = tagId; State = state; state.StateChanged += new System.Action(OnStateChanged); }
public void CopyToXState(XState state) { state.StateClasses = StateClasses.ToList(); state.StateClass = StateClass; state.AdditionalStates = AdditionalStates.ToList(); state.OnDelay = OnDelay; state.OffDelay = OffDelay; state.HoldDelay = HoldDelay; if (IsInitialState || IsSuspending || IsNoLicense || IsConnectionLost) { state.AdditionalStates = new List<XAdditionalState>(); state.OnDelay = 0; state.OffDelay = 0; state.HoldDelay = 0; } }