Example #1
0
    /// <summary>
    /// Display information about the Switch device
    /// </summary>
    /// <param name="owd"> OneWireContainer device </param>
    internal static void printSwitchInfo(SwitchContainer swd)
    {
        try
        {
            byte[] state = swd.readDevice();

            Debug.WriteLine("");
            Debug.WriteLine("-----------------------------------------------------------------------");
            Debug.WriteLine("| Number of channels: " + swd.getNumberChannels(state));
            Debug.WriteLine("| Is high-side switch: " + swd.HighSideSwitch);
            Debug.WriteLine("| Has Activity Sensing: " + swd.hasActivitySensing());
            Debug.WriteLine("| Has Level Sensing: " + swd.hasLevelSensing());
            Debug.WriteLine("| Has Smart-on: " + swd.hasSmartOn());
            Debug.WriteLine("| Only 1 channel on at a time: " + swd.onlySingleChannelOn());
            Debug.WriteLine("");

            Debug.Write("    Channel          ");
            for (int ch = 0; ch < swd.getNumberChannels(state); ch++)
            {
                Debug.Write(ch + "      ");
            }
            Debug.WriteLine("");

            Debug.WriteLine("    -----------------------------------");

            Debug.Write("    Latch State      ");
            for (int ch = 0; ch < swd.getNumberChannels(state); ch++)
            {
                Debug.Write(((swd.getLatchState(ch, state) == true) ? "ON     " : "OFF    "));
            }
            Debug.WriteLine("");

            if (swd.hasLevelSensing())
            {
                Debug.Write("    Sensed Level     ");
                for (int ch = 0; ch < swd.getNumberChannels(state); ch++)
                {
                    Debug.Write(((swd.getLevel(ch, state) == true) ? "HIGH   " : "LOW    "));
                }
                Debug.WriteLine("");
            }

            if (swd.hasActivitySensing())
            {
                Debug.Write("    Sensed Activity  ");
                for (int ch = 0; ch < swd.getNumberChannels(state); ch++)
                {
                    Debug.Write(((swd.getSensedActivity(ch, state) == true) ? "SET    " : "CLEAR  "));
                }
                Debug.WriteLine("");
            }
        }
        catch (OneWireIOException e)
        {
            Debug.WriteLine(e);
        }
    }