private void timer_Tick(object sender, EventArgs e) { if (relay1.isOnline()) { if (relay1.get_state() == YRelay.STATE_B) // active { relay1.set_state(YRelay.STATE_A); } else if (relay1.get_state() == YRelay.STATE_A) // idle { relay1.set_state(YRelay.STATE_B); } } if (relay2.isOnline()) { if (relay2.get_state() == YRelay.STATE_B) // active { relay2.set_state(YRelay.STATE_A); } else if (relay2.get_state() == YRelay.STATE_A) // idle { relay2.set_state(YRelay.STATE_B); } } }
/** * <summary> * Returns the state of the relays (A for the idle position, B for the active position). * <para> * </para> * <para> * </para> * </summary> * <returns> * either <c>YRelay.STATE_A</c> or <c>YRelay.STATE_B</c>, according to the state of the relays (A for * the idle position, B for the active position) * </returns> * <para> * On failure, throws an exception or returns <c>YRelay.STATE_INVALID</c>. * </para> */ public int get_state() { if (_func == null) { throw new YoctoApiProxyException("No Relay connected"); } // our enums start at 0 instead of the 'usual' -1 for invalid return(_func.get_state() + 1); }