public CurtainState(CurtainState state) : base(state) { Action = state.Action; Channel = state.Channel; Position = state.Position; }
public override void ApplyState(DeviceBase.DeviceState state) { base.ApplyState(state); CurtainState currentState = (CurtainState)mState; CurtainState newState = (CurtainState)state; Debug.Assert(newState.Channel == currentState.Channel); // FIXME - Disable prediction since we're getting out of sync somehow. //if (newState.Action != currentState.Action) { switch (newState.Action) { case Key.Up: Up(); break; case Key.Stop: Stop(); break; case Key.Down: Down(); break; } } }
private void RunCommand(Key key) { CurtainState state = (CurtainState)mState; // size, payload[size] byte[] data = new byte[] { (byte)3, (byte)DEVICE_ID, (byte)state.Channel, (byte)key }; mService.SendData(data); mLastCommand = key; state.Action = key; }
public CurtainDevice(DeviceCreationInfo creationInfo) : base(new CurtainState(), creationInfo) { mService = (CurtainService)creationInfo.ServiceManager.GetService(typeof(CurtainService)); CurtainState state = (CurtainState)mState; state.Channel = int.Parse(creationInfo.Configuration.channel); mVoiceName = creationInfo.Configuration.voiceName; /* * // TOTO - Look into this in detail. * // Somehow we're getting garbage in the first submission with MS serial implementation. * // No issues in the previous python implementation, but required beefing up error handling on the arduino side as well * // as adding an extra flush from the c# side. * byte[] dummy = new byte[] { (byte)'\n' }; * mService.SendData(dummy); */ }
private void GameManager_Update() { switch (state) { case CurtainState.Closed: state = Closed(); break; case CurtainState.Opening: state = Opening(); break; case CurtainState.Open: state = Opened(); break; case CurtainState.Closing: state = Closing(); break; } }
private void PredictPosition() { CurtainState state = (CurtainState)mState; const int syncDuration = 18500; DateTime currTime = DateTime.Now; TimeSpan diff = mLastTime - currTime; mLastTime = currTime; // Fixme. Add better prediction. if (diff.Milliseconds > syncDuration) { if (mLastCommand == Key.Up) { state.Position = 1.0f; } else if (mLastCommand == Key.Down) { state.Position = 0.0f; } } }
protected CurtainDeviceBase(CurtainState state, DeviceCreationInfo creationInfo) : base(state, creationInfo) { }
public CurtainState(CurtainState state) : base(state) { }