public void turnSwitch(String pinName, String state)
        {
            PinSwitch s           = _pins[pinName] as PinSwitch;
            bool      targetState = state == "1" ? true : state == "0" ? false : !s.fnState;

            onSwitchHandler(pinName, targetState);
        }
        public void setSwitchState(string pin, bool fnState)
        {
            PinSwitch s = _pins[pin] as PinSwitch;

            if (s.fnState != fnState)
            {
                s.fnState = fnState;
                DriverEmu.Instance.executeFile(@"..\data\scripts\" + (fnState ? s.onHigh : s.onLow));
            }
        }
        public void onSwitchHandler(string pin, bool newState)
        {
            PinSwitch s = _pins[pin] as PinSwitch;

            if (s.type == '1')
            {
                if (newState)
                {
                    setSwitchState(pin, !s.fnState);
                }
            }
            else if (s.type == '2')
            {
                setSwitchState(pin, newState);
            }
            else     // stair switch
            {
                setSwitchState(pin, !s.fnState);
            }
        }