public StateChangeAdorner(TextBox adornedElement, StateChange change) : base(adornedElement) { this.text.FontSize = adornedElement.FontSize * 0.80; this.text.Text = change.Variable + " = " + change.Value; this.border.Child = this.text; }
private void StateChangedEventHandler(object sender, StateChangedEventArgs args) { var newState = ConvertStateChangeEventArgs(args); ReadyState = newState.NewState; StateChange?.Invoke(this, newState); }
private void severConnection_StateChanged(StateChange State) { switch (State.NewState) { case ConnectionState.Connected: //connectionMessage = "Connected....."; new FadeText(this, new Vector2(10, 10), "Connected.."); Connected = true; startGame(); break; case ConnectionState.Disconnected: new FadeText(this, new Vector2(10, 10), "F**k.."); if (State.OldState == ConnectionState.Connected) { connectionMessage = "Lost Connection....."; } Connected = false; break; case ConnectionState.Connecting: connectionMessage = "Connecting....."; Connected = false; break; } }
private void OnNext(StateChange <ClimateEntity, EntityState <ClimateAttributes> > e) { // event has 3 properties ClimateEntity entity = e.Entity; EntityState <ClimateAttributes>?newSate = e.New; EntityState <ClimateAttributes>?oldState = e.Old; var currentState = e.Entity.EntityState; // should be the same as e.New (unless the was another change in the meantime) string area = e.Entity.Area; string?state = e.Entity.State; // attribute properties are strong typed double temperature = e.New?.Attributes?.Temperature ?? 0; double?temperatureDelta = e.New?.Attributes?.Temperature - e.Old?.Attributes?.Temperature; // dump as json to view the structure var asJson = JsonSerializer.Serialize(e, new JsonSerializerOptions() { WriteIndented = true }); Console.WriteLine(asJson); Console.WriteLine($"{e}"); Console.WriteLine($"{e.New?.Attributes}"); }
void ConnectionStateChange(StateChange change) { Logger.Info("SignalR: {0} -> {1}", change.OldState, change.NewState); switch (change.NewState) { case Microsoft.AspNet.SignalR.Client.ConnectionState.Connecting: case Microsoft.AspNet.SignalR.Client.ConnectionState.Reconnecting: _state.OnNext(new ConnectionDown(_connection)); RxMessageBrokerMinimod.Default.Send(ConnectionState.Connecting); return; case Microsoft.AspNet.SignalR.Client.ConnectionState.Disconnected: _state.OnNext(new ConnectionDown(_connection)); RxMessageBrokerMinimod.Default.Send(ConnectionState.Disconnected); return; case Microsoft.AspNet.SignalR.Client.ConnectionState.Connected: _state.OnNext(new ConnectionUp(_connection)); RxMessageBrokerMinimod.Default.Send(ConnectionState.Connected); return; } }
private void OnStateChanged(StateChange stateChange) { if (StateChanged != null) { StateChanged(stateChange); } }
public bool ScheduleChange(MeshNetworkIdentity id, StateChange change, ref IDContainer idReference) { //Debug.Log("Schedule change: my identity has objectID = " + GetIdentity().GetObjectID()); if (GetIdentity().meshnetReference.database == null) { Debug.LogError("Can't schedule a state change without an active database"); return(false); } ushort transactionID = GetNextTransactionID(); callbackRegistry.Add(transactionID, idReference); callbackTimers.Add(transactionID, Time.time); StateChangeTransaction transaction = new StateChangeTransaction(transactionID, change, id); MeshPacket p = new MeshPacket(); p.SetContents(transaction.GetSerializedBytes()); p.SetPacketType(PacketType.DatabaseChangeRequest); //Debug.Log("Setting packet with source object ID = " + GetIdentity().GetObjectID()); p.SetSourceObjectId(GetIdentity().GetObjectID()); p.SetSourcePlayerId(GetIdentity().meshnetReference.GetLocalPlayerID()); p.SetTargetObjectId((ushort)ReservedObjectIDs.DatabaseObject); p.SetTargetPlayerId(netDB.GetIdentity().GetOwnerID()); GetIdentity().RoutePacket(p); return(true); }
private string GetNicifiedString(StateChange <DeviceState> stateChange) { switch (stateChange.Next) { case DeviceState.Disconnected: if (stateChange.Previous == DeviceState.Calibrating) { return("Calibrated!"); } return("Disconnected"); case DeviceState.Initializing: return("Initializing"); case DeviceState.Connected: return("Connected"); case DeviceState.Streaming: return("Streaming"); case DeviceState.Calibrating: return("Calibrating"); } return(""); }
private void SetStatusTextColor(Text text, StateChange <DeviceState> stateChange) { if (stateChange.Previous == DeviceState.Calibrating) { text.color = Color.cyan; return; } switch (stateChange.Next) { case DeviceState.Streaming: text.color = Color.green; return; case DeviceState.Initializing: text.color = Color.yellow; return; case DeviceState.Calibrating: text.color = Color.cyan; return; default: text.color = Color.white; return; } }
public void test_add_existing_aspect() { NoteAspect note = new NoteAspect("This is a test note"); StateAspectAdd noteAdd = new StateAspectAdd(note); StateAspectRemove noteRemove = new StateAspectRemove(noteAdd.aspect_id); //TODO: update StateChange stateChange = new StateChange(); // test pre-existing add stateChange.addChange(StateAspect.NOTE, noteAdd); Assert.ThrowsException <InvalidAspect>(() => { stateChange.addChange(StateAspect.NOTE, noteAdd); }); //TODO: update Assert.ThrowsException <InvalidAspect>(() => { stateChange.addChange(StateAspect.NOTE, noteRemove); }); // clean up and verify we're still in a good state stateChange.removeChange(StateAspect.NOTE, noteAdd.aspect_id); Assert.AreEqual(stateChange.additions.Count, 0); Assert.AreEqual(stateChange.updates.Count, 0); Assert.AreEqual(stateChange.removals.Count, 0); //TODO: test pre-existing update // test pre-existing removal stateChange.addChange(StateAspect.NOTE, noteRemove); Assert.ThrowsException <InvalidAspect>(() => { stateChange.addChange(StateAspect.NOTE, noteAdd); }); //TODO: update Assert.ThrowsException <InvalidAspect>(() => { stateChange.addChange(StateAspect.NOTE, noteRemove); }); // clean up and verify we're still in a good state stateChange.removeChange(StateAspect.NOTE, noteRemove.aspect_id); Assert.AreEqual(stateChange.additions.Count, 0); Assert.AreEqual(stateChange.updates.Count, 0); Assert.AreEqual(stateChange.removals.Count, 0); }
private void ServerConnection_StateChanged(StateChange State) { switch (State.NewState) { case ConnectionState.Connected: connectionMessage = "Connected......"; Connected = true; //startGame(); break; case ConnectionState.Disconnected: connectionMessage = "Disconnected....."; if (State.OldState == ConnectionState.Connected) { connectionMessage = "Lost Connection...."; } Connected = false; break; case ConnectionState.Connecting: connectionMessage = "Connecting....."; Connected = false; break; } }
private async void HubConnectionStateChanged(StateChange connectionState) { OldConnectionState = connectionState.OldState; ConnectionState = connectionState.NewState; if (connectionState.NewState == ConnectionState.Disconnected) { RaiseConnectionEvent(Disconnected); if (CrossConnectivity.Current.IsConnected) { RaiseConnectionEvent(Connecting); await HubConnection.Start(); } } else { if (connectionState.NewState == ConnectionState.Connected) { RaiseConnectionEvent(Connected); } else { if (connectionState.NewState == ConnectionState.Reconnecting) { RaiseConnectionEvent(Reconnecting); } } } }
private static void HubConnectionStateChanged(StateChange stateChange) { Console.WriteLine( "Hub connection's state has changed from oldstate: {0} to new state: {1}", stateChange.OldState, stateChange.NewState); }
/// <summary> /// Incomming connection change /// </summary> /// <param name="state">State change</param> private void ConnChangedState(StateChange state) { Invoke(new Action(() => { switch (state) { case StateChange.Connected: Connected(); break; case StateChange.Disconnected: Disconnected(); break; case StateChange.ConnectionError: Disconnected(); MessageBox.Show("Connection error!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); break; case StateChange.Started: Started(); break; case StateChange.Stopped: Stopped(); break; case StateChange.NewData: break; } })); }
private async Task ProcessWorkItemRevision(WorkItem workItemRev, WorkItemRevisionBuilder revs) { var stateChange = new StateChange { State = workItemRev.State(), Reason = workItemRev.Reason(), By = workItemRev.ChangedByNameOnly() }; if (revs.TfsInfo == null) { // we just want the latest info for work item. might be able to grab from just the // last revision var workItem = await this.workItemClient.GetWorkItemAsync(workItemRev.Id.Value); revs.TfsInfo = new TfsInfo { Id = workItem.Id.Value, Title = workItem.Title(), Type = workItem.Type(), State = workItem.State(), Iteration = workItem.IterationPath(), Tags = workItem.Tags(), Priority = workItem.Priority(), ClosedDate = workItem.ClosedDate() }; if (workItemRev.IsBug()) { revs.TfsInfo.Severity = workItem.Severity(); } } var stateChangeDate = workItemRev.StateChangeDate(); if (stateChangeDate != null) { if (revs.LastStateChangeDate != null) { stateChange.StateChangeDate = stateChangeDate.Value; var diff = stateChange.StateChangeDate - revs.LastStateChangeDate.Value; stateChange.DurationText = diff.Humanize(); } else { stateChange.StateChangeDate = workItemRev.CreatedDate(); } revs.LastStateChangeDate = stateChangeDate; } revs.States.Add(stateChange); lock (this.lockObject) { this.revisionsCount++; } }
public override void CopyInfo(SerializedClass info) { LevelStateChangeInfo i = (LevelStateChangeInfo)info; levelName = i.LevelName; stateName = i.ModifierName; action = i.Action; }
protected override void IdleAction() { if (!PathFinderReady) { return; } StateChange.ToFindTargetState(); }
private void Start() { if (!isTitleScreen) { ChangeState(GameState.CARD_SELECT); } OnStateChange += StateChanged; }
void Connection_StateChanged(StateChange obj) { logger.Log(string.Format("SignalR connection status changed. Old State: {0}, NewState: {1}", obj.OldState, obj.NewState)); if (obj.OldState == ConnectionState.Connected && obj.NewState == ConnectionState.Disconnected) { ConnectAsync(); } }
void _hubConnection_StateChanged(StateChange obj) { Log.InfoFormat("Connection={0}", _hubConnection.State); if (_hubConnection.State == ConnectionState.Connected || _hubConnection.State == ConnectionState.Disconnected) { _connectionStable = true; } }
private void ConnectionOnStateChanged(StateChange obj) { _log.Debug("State changed to " + obj.NewState); if (StatusChanged != null) { StatusChanged(obj); } }
private void ChangeState(RdpState state, int?reason = null) { State = state; btnConnect.Enabled = state == RdpState.Disconnected; btnDisconnect.Enabled = state == RdpState.Connected; StateChange?.Invoke(this, new StateChangeEventArgs(CurrentServer, state, ListIndex, reason)); }
private void Connection_StateChanged(StateChange stateChanging) { if (stateChanging.NewState == ConnectionState.Connected) { ConnectionSuccess(Connection.ConnectionId); HubProxy.Invoke(START_ADMIN, UserName); } }
private void CloseTransfert() { DisplayRenderFragment = null; StateChange.Invoke(); TransfertRackValidation = new TransfertRackValidation(); ClientTransfert = new CommandeView(); }
void Connection_StateChanged(StateChange obj) { var info = Connection; //var dispatcher = Application.Current.Dispatcher; //var message = string.Format("Connection_StateChanged {0,15} -> {1,-15}\n", obj.OldState, obj.NewState); //dispatcher.Invoke(() => teLogStream.Text += message); }
/// <summary> /// Adds a listener for the given state. It is invoked when the given state is left /// </summary> /// <param name="s">the state when it is left should trigger the listener</param> /// <param name="delegater">the listener</param> public void AddStateLeaveListener(State s, StateChange delegater) { if (!IsStateRegistered(s)) { throw new Exception(String.Format("State \"{0}\" wasn't registered!", s.Name)); } StateLeaveListeners[s].Add(delegater); }
//Send delta containing an object private void SendObjectUpdate(MeshNetworkIdentity id, StateChange s) { Dictionary <Player, StateChange> playerListDelta = new Dictionary <Player, StateChange>(); Dictionary <MeshNetworkIdentity, StateChange> objectListDelta = new Dictionary <MeshNetworkIdentity, StateChange>(); objectListDelta.Add(id, s); SendDelta(playerListDelta, objectListDelta, (ulong)ReservedPlayerIDs.Broadcast, false); }
/// <summary> /// Invoke event for connection state changes. /// </summary> /// <param name="newState">The new WebSocketState.</param> protected virtual void OnStateChange(WebSocketState newState) { if (_Status != newState) { _Status = newState; StateChange?.Invoke(this, newState); } }
private void HubConnect_StateChanged(StateChange obj) { if (obj.NewState == ConnectionState.Connected) { SinglarConnectedEvent?.Invoke(); // await Start(); } }
private void _connection_StateChanged(StateChange obj) { Debug.WriteLine(string.Format("ConnectionStateChanged {0}", obj.NewState)); if (obj.NewState == ConnectionState.Reconnecting || obj.NewState == ConnectionState.Disconnected) { OnLostConnection(); } }
private void Connection_StateChanged(StateChange State) { // Wait for a connection and start if we have connected if (State.NewState == ConnectionState.Connected) { Started = true; } }
/// <summary>Called, when a reset or halt was processed.</summary> /// <param name="item">Processor, which was resetted/halted.</param> private void StateChanged(IDispatcherItem item, StateChange stateChange) { var group = Clients.Group(item.Guid.ToString()); switch (stateChange) { case StateChange.SoftReset: group.Reset(); break; case StateChange.Halt: group.Halt(); break; case StateChange.HardReset: group.HardReset(); break; } }
private void DebugLogStateChanges() { const int STATE_BUFFER_SIZE = 1024; if (!mDebugLogStateChangesInitialized) { mDebugLogStateChangesInitialized = true; System.Array.Copy(mRegisters, mOldRegisters, 128); mStateChangeInstCount = 0; MoSync.Util.WriteTextToFile("", "stateChanges.txt", FileMode.Create); mStateChangeOldMemory = new byte[mDataMemory.GetSizeInBytes()]; mDataMemory.ReadBytes(mStateChangeOldMemory, 0, mDataMemory.GetSizeInBytes()); } int i = 128; mStateChangeInstCount++; while ((i--) != 0) { if (mOldRegisters[i] != mRegisters[i]) { StateChange stateChange = new StateChange(); stateChange.type = 0; stateChange.ip = mIp; stateChange.reg = i; stateChange.before = mOldRegisters[i]; stateChange.after = mRegisters[i]; stateChange.instCount = mStateChangeInstCount; mStateChanges.Add(stateChange); if (mStateChanges.Count >= STATE_BUFFER_SIZE) { DebugWriteStateChanges(); mStateChanges.Clear(); } mOldRegisters[i] = mRegisters[i]; } } for (i = 0; i < mStateChangeOldMemory.Length; i++) { byte newByte = mDataMemory.ReadUInt8(i); if (mStateChangeOldMemory[i] != newByte) { StateChange stateChange = new StateChange(); stateChange.type = 1; stateChange.ip = mIp; stateChange.address = i; stateChange.before = mStateChangeOldMemory[i]; stateChange.after = newByte; stateChange.instCount = mStateChangeInstCount; mStateChanges.Add(stateChange); if (mStateChanges.Count >= STATE_BUFFER_SIZE) { DebugWriteStateChanges(); mStateChanges.Clear(); } mStateChangeOldMemory[i] = newByte; } } }
private void ReportChange(StateChange change) { if (change.NewState == ConnectionState.Connected) { _Connected = true; ShowProgress(true); GetKpiList("Sales"); GetKpiList("CashFlow"); GetKpiList("Expense"); ShowProgress(false); } else if (change.OldState == ConnectionState.Connected) { _Connected = false; ShowProgress(true); } }
public StateChangeEventArgs(StateChange _currState, string _TextDescription) { currState = _currState ; TextDescription = _TextDescription; }
/// <summary> /// Connection_s state changed. /// </summary> /// <param name="obj">The object.</param> private void Connection_StateChanged(StateChange obj) { if (obj.NewState == ConnectionState.Disconnected && !isStoppedCalled && this.workstation.IsNetworkAvailable) { Connect(null, false); } }
/// <summary> /// Generates the code for a StateChange node. /// </summary> /// <param name = "sc">The StateChange node.</param> /// <returns>String containing C# code for StateChange sc.</returns> private string GenerateStateChange(StateChange sc) { //State is in the LSL_Api because it requires a ref to the ScriptEngine, which we can't have in the ScriptBase string retStr = GenerateLine("try", null); retStr += GenerateLine("{", null); retStr += Generate( String.Format("((ILSL_Api)m_apis[\"ll\"]).state(\"{0}\");", sc.NewState) , sc); retStr += GenerateLine("}", null); retStr += GenerateLine("catch", null); retStr += GenerateLine("{", null); retStr += GenerateLine("yield break;", null); retStr += GenerateLine("}", null); return retStr; }
public void Update(StateChange[] changes) { foreach (var change in changes) { Cell cell = change.Cell; Monster monster = change.Monster; Player player = change.Player; Potion potion = change.Potion; if (change.Action == Action.Add) { if (monster != null) monsters.Add(monster); if (player != null) players.Add(player); if (potion != null) potions.Add(potion); } else if (change.Action == Action.Remove) { if (monster != null) monsters.RemoveAll(m => m.Id == monster.Id); if (potion != null) potions.RemoveAll(p => p.Id == potion.Id); } else if (change.Action == Action.Update) { if (cell != null) Cells[cell.Y, cell.X] = cell; if (monster != null) monsters[monsters.FindIndex(m => m.Id == monster.Id)] = monster; if (player != null) players[players.FindIndex(p => p.Id == player.Id)] = player; if (potion != null) potions[potions.FindIndex(p => p.Id == potion.Id)] = potion; } } }
protected override StateChangeReturn OnChangeState (StateChange transition) { if (transition == StateChange.ReadyToPaused) src.StartTask (loop); else if (transition == StateChange.PausedToReady) src.StopTask (); return StateChangeReturn.Success; }
// Writes an entry to the alarm log when the alarm state changes. private void LogStateChange(Guid signalID, Alarm oldState, Alarm newState, DateTime timestamp, double value) { int? oldStateID; int? newStateID; if (m_useAlarmLog) { oldStateID = ((object)oldState != null) ? oldState.ID : (int?)null; newStateID = ((object)newState != null) ? newState.ID : (int?)null; StateChange stateChange = new StateChange() { SignalID = signalID, OldStateID = oldStateID, NewStateID = newStateID, Timestamp = timestamp, Value = value }; m_stateChanges.Enqueue(new StateChange[] { stateChange }); m_alarmLogOperation.RunOnceAsync(); } }
/// <summary> /// Generates the code for a StateChange node. /// </summary> /// <param name="sc">The StateChange node.</param> /// <returns>String containing C# code for StateChange sc.</returns> private string GenerateStateChange(StateChange sc) { //State is in the LSL_Api because it requires a ref to the ScriptEngine, which we can't have in the ScriptBase StringBuilder retVal = new StringBuilder(); retVal.Append(GenerateLine("try", null)); retVal.Append(GenerateLine("{", null)); retVal.Append(Generate( String.Format("((ILSL_Api)m_apis[\"ll\"]).state(\"{0}\");", sc.NewState) , sc)); retVal.Append(GenerateLine("}", null)); retVal.Append(GenerateLine("catch", null)); retVal.Append(GenerateLine("{", null)); retVal.Append(GenerateLine("yield break;", null)); retVal.Append(GenerateLine("}", null)); return retVal.ToString(); }
/// <summary>Notifies, when a reset or halt request finished execution.</summary> /// <param name="item">Processor, which changed.</param> private void NotifyStateChanged(IDispatcherItem item, StateChange stateChange) { Action<IDispatcherItem, StateChange> handler; lock (eventLock) { handler = stateChanged; } if (handler != null) { handler(item, stateChange); } }
private async void OnStatechange(StateChange obj) { await App.Debug.LogAsync(string.Format("State changed from {0} to {1}.", obj.OldState, obj.NewState)); }