Пример #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();
     }
 }
Пример #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");
 }
Пример #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");
 }
Пример #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);
     }
 }