示例#1
0
 public CurtainState(CurtainState state)
     : base(state)
 {
     Action   = state.Action;
     Channel  = state.Channel;
     Position = state.Position;
 }
示例#2
0
        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;
                }
            }
        }
示例#3
0
        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;
        }
示例#4
0
        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);
 */
        }
示例#5
0
        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;
            }
        }
示例#6
0
        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;
                }
            }
        }
示例#7
0
 protected CurtainDeviceBase(CurtainState state, DeviceCreationInfo creationInfo)
     : base(state, creationInfo)
 {
 }
示例#8
0
 public CurtainState(CurtainState state)
     : base(state)
 {
 }
示例#9
0
 public CurtainState(CurtainState state)
     : base(state)
 {
     Action = state.Action;
     Channel = state.Channel;
     Position = state.Position;
 }
示例#10
0
 protected CurtainDeviceBase(CurtainState state, DeviceCreationInfo creationInfo)
     : base(state, creationInfo)
 {
 }
示例#11
0
 public CurtainState(CurtainState state)
     : base(state)
 {
 }