Ejemplo n.º 1
0
 void RegisterChannel(int antChannel, PowerChannel c)
 {
     c.OnSearchEnded        += ChannelSearchEnded;
     c.OnAccumPowerReceived += ChannelAccumPowerReceived;
     c.OnClosed             += ChannelClosed;
     lock (this)
     {
         channels.Add((byte)antChannel, c);
         c.Open();
     }
 }
Ejemplo n.º 2
0
 void ChannelAccumPowerReceived(PowerChannel sender, int accumPower, int count)
 {
     foreach (var kvp in channels)
     {
         if (kvp.Value == sender)
         {
             OnAccumPowerReceived?.Invoke(this, kvp.Key, accumPower, count);
             return;
         }
     }
     throw new Exception("channels inconsistency");
 }
Ejemplo n.º 3
0
 void ChannelSearchEnded(PowerChannel sender, bool isConnected, int deviceNumber)
 {
     foreach (var kvp in channels)
     {
         if (kvp.Value == sender)
         {
             OnSearchEnded?.Invoke(this, kvp.Key, isConnected, deviceNumber);
             return;
         }
     }
     throw new Exception("channels inconsistency");
 }
Ejemplo n.º 4
0
 void ChannelClosed(PowerChannel sender)
 {
     lock (this)
     {
         byte i = 255;
         foreach (var kvp in channels)
         {
             if (kvp.Value == sender)
             {
                 i = kvp.Key;
                 break;
             }
         }
         if (i == 255)
         {
             throw new Exception("channels inconsistency");
         }
         channels.Remove(i);
     }
 }