Exemple #1
0
        /// <summary>
        /// Put the data from the loc state into this slot.
        /// </summary>
        protected void UpdateSlotFromLoc(Slot slot, ILocState l)
        {
            slot.Address = l.Address.ValueAsInt;
            var spd = l.SpeedInSteps.Actual;

            slot.Speed = (spd == 1) ? 2 : spd;
            var dirf = DirFunc.None;

            if (l.Direction.Actual == LocDirection.Reverse)
            {
                dirf |= DirFunc.Direction;
            }
            if (l.F0.Actual)
            {
                dirf |= DirFunc.F0;
            }
            if (l.GetFunctionActualState(LocFunction.F1))
            {
                dirf |= DirFunc.F1;
            }
            if (l.GetFunctionActualState(LocFunction.F2))
            {
                dirf |= DirFunc.F2;
            }
            if (l.GetFunctionActualState(LocFunction.F3))
            {
                dirf |= DirFunc.F3;
            }
            if (l.GetFunctionActualState(LocFunction.F4))
            {
                dirf |= DirFunc.F4;
            }
            slot.DirF = dirf;
            var snd = Sound.None;

            if (l.GetFunctionActualState(LocFunction.F5))
            {
                snd |= Sound.Snd1;
            }
            if (l.GetFunctionActualState(LocFunction.F6))
            {
                snd |= Sound.Snd2;
            }
            if (l.GetFunctionActualState(LocFunction.F7))
            {
                snd |= Sound.Snd3;
            }
            if (l.GetFunctionActualState(LocFunction.F8))
            {
                snd |= Sound.Snd4;
            }
            slot.Sound = snd;
        }
Exemple #2
0
        /// <summary>
        /// Actual state of this loc has changed
        /// </summary>
        private void OnLocActualStateChanged(object sender, EventArgs e)
        {
            if (loc == null)
            {
                return;
            }
            tbSpeed.Value = loc.Speed.Actual;
            var direction     = loc.Direction.Actual;
            var activeColor   = Color.GreenYellow;
            var inActiveColor = SystemColors.Control;

            cmdForward.Enabled   = (direction == LocDirection.Reverse);
            cmdForward.BackColor = (direction == LocDirection.Forward) ? activeColor : inActiveColor;
            cmdReverse.Enabled   = (direction == LocDirection.Forward);
            cmdReverse.BackColor = (direction == LocDirection.Reverse) ? activeColor : inActiveColor;
            cbF0.Checked         = loc.F0.Actual;
            foreach (var pair in functionCheckboxes)
            {
                pair.Value.Checked = loc.GetFunctionActualState(pair.Key);
            }
        }