Beispiel #1
0
 public IEnumerable<IControlMessage> GetControllMessagesForEndpointState(IEndpointState state, IHardwareEndpoint hardwareEndpoint)
 {
     var hwid = hardwareEndpoint.HardwareEndpointIndentifiers.First ().ID;
     var message = ControlFactory.GetControlMessage () as NCDControllMessage;
     if (message != null)
     {
         message.Bank = byte.Parse (hwid.Substring (1, hwid.IndexOf (":") - 1));
         message.Relay = byte.Parse (hwid.Substring (hwid.IndexOf (":") + 1));
         if (state != null)
         {
             switch (state.Name)
             {
                 case "On":
                     message.Status = 1;
                     yield return message;
                     break;
                 case "Off":
                     message.Status = 0;
                     yield return message;
                     break;
                 default:
                     message.Status = 0;
                     yield return message;
                     break;
             }
         }
     }
 }
Beispiel #2
0
 private static Dictionary<int, bool> SelectState(IHardwareEndpoint endpoint, IEnumerable<KeyValuePair<int, IEnumerable<bool>>> currentState)
 {
     var retval = new Dictionary<int, bool>();
     foreach (var hardwareEndpointIndentifier in endpoint.HardwareEndpointIndentifiers)
     {
         var hwid = hardwareEndpointIndentifier.ID;
         var bank = ushort.Parse(hwid.Substring(1, hwid.IndexOf(":") - 1));
         var relayid = ushort.Parse(hwid.Substring(hwid.IndexOf(":") + 1));
         retval.Add(currentState.First(kv => kv.Key == bank).Key,
                    currentState.First(kv => kv.Key == bank).Value.ElementAt(relayid));
     }
     return retval;
 } 
Beispiel #3
0
 public IEnumerable<IControlMessage> GetControllMessagesForEndpointState(IEndpointState state, IHardwareEndpoint hardwareEndpoint)
 {
     yield return ControlFactory.GetControlMessage();
 }
Beispiel #4
0
 public IEnumerable<IControlMessage> GetControllMessagesForEndpointState(IEndpointState state, IHardwareEndpoint hardwareEndpoint)
 {
     throw new NotImplementedException();
 }