示例#1
0
        public static void PollNUTServer(string nutIP, ushort nutPort)
        {
            string s = null;

            if (NUTInitialization.isSimulated)
            {
                // If simulation is enabled, then it will receive data from the simulator instead of the UPS

                // TODO: Format simulation files to adhere to UPS variable format
                //NUTProcessor.UPSVariables = Tuple.Create(SimulateNUTServer());
                return;
            }


            Task NUTConnection = Task.Run(async() =>
            {
                NUTInitialization.debugLog.Trace("[POLLER] Executing telnet client task");
                s = await TelnetClient(nutIP, nutPort).ConfigureAwait(true);
            });

            Task.WaitAll(NUTConnection);
            NUTConnection.Dispose();

            NUTInitialization.isPolling = true;
            NUTProcessor.ParseNUTOutput(s); // Pipes to the parser so that the new data can be processed
            return;
        }
示例#2
0
        public static async Task <bool> ValidateNUTServer(string nutIP, ushort nutPort)
        {
            string s             = null;
            Task   NUTConnection = Task.Run(async() =>
            {
                NUTInitialization.debugLog.Trace("[POLLER:VALIDATE] Executing telnet client task");
                s = await TelnetClient(nutIP, nutPort).ConfigureAwait(true);
            });

            Task.WaitAll(NUTConnection);

            NUTConnection.Dispose();
            NUTInitialization.debugLog.Info("ValidateNUTServer task " + NUTConnection.Status.ToString());

            Tuple <List <string>, bool> NUTValidation = NUTProcessor.ValidateNUTOutput(s);

            return(NUTValidation.Item2);
        }