Пример #1
0
 private int AdaptRelayState(MockedRelay r)
 {
     /*
      * Takes
      *  1) Relay's state
      *      when null uses DefaultState
      *      when null defaults to false
      *  2) When false returns 0
      *      when true returns 1
      */
     return(r?.State ?? DefaultState ?? false ? 1 : 0);
 }
Пример #2
0
        private void AddRelay(MockedRelay r)
        {
            //if (WorkingMode == MockWorkingMode.Limited && RelayCount >= mockedRelays.Count)
            //    throw new InvalidOperationException($"Unable to add a new mocked relay to the internal state collection. Wokring mode is {WorkingMode}, mocked driver is configured to accept {RelayCount} and internal state contains already {mockedRelays.Count} instances.");

            //if (WorkingMode == MockWorkingMode.Limited && r.Index >= mockedRelays.Count)
            //    throw new InvalidOperationException($"Index {r.Index} is greather than the number of accepted relay {RelayCount}");

            if (mockedRelays.Any(sr => sr.Index == r.Index))
            {
                mockedRelays.Remove(mockedRelays.FirstOrDefault(sr => sr.Index == r.Index));
                //throw new InvalidOperationException($"Index {r.Index} already exists into the internal mocked relay store.");
            }
            mockedRelays.Add(r);
        }
Пример #3
0
 private void SetState(MockedRelay mockedRelay, bool?state)
 {
     mockedRelay.State = state;
 }