int ReceiveHealthData()
        {
            int rtn = 9;

            try
            {
                healthData = system_main.ReceiveHealth(3000000);
                for (UInt32 j = 0; j < healthData.Count; j++)
                {
                    GoHealthMsg healthmsg = (GoHealthMsg)healthData.Get(j);
                    for (UInt32 k = 0; k < healthmsg.Count; k++)
                    {
                        GoIndicator healthIndicator = healthmsg.Get(k);
                        healthIdicator_id.Add(healthIndicator.id);
                        healthIdicator_instance.Add(healthIndicator.instance);
                        healthIdicator_value.Add(healthIndicator.value);
                    }
                }
            }
            catch (KException ex)
            {
                rtn = (int)ex.Status;
            }
            return(rtn);
        }
示例#2
0
        static int Main(string[] args)
        {
            try
            {
                KApiLib.Construct();
                GoSdkLib.Construct();
                GoSystem   system = new GoSystem();
                GoSensor   sensor;
                GoDataSet  healthData = new GoDataSet();
                KIpAddress ipAddress  = KIpAddress.Parse(Constants.SENSOR_IP);
                sensor = system.FindSensorByIpAddress(ipAddress);
                sensor.Connect();
                system.EnableData(true);

                UInt32 i = 1;
                while (i < 10)
                {
                    healthData = system.ReceiveHealth(30000000);
                    for (UInt32 j = 0; j < healthData.Count; j++)
                    {
                        GoHealthMsg healthMsg = (GoHealthMsg)healthData.Get(j);
                        Console.WriteLine("Health message received:");
                        Console.WriteLine(" Number of indicators: {0}", healthMsg.Count);
                        for (UInt32 k = 0; k < healthMsg.Count; k++)
                        {
                            GoIndicator healthIndicator = healthMsg.Get(k);
                            Console.WriteLine(" Indicator[{0}]: Id:{1} Instance:{2} Value{3}", k, healthIndicator.id, healthIndicator.instance, healthIndicator.value);
                        }
                        // Dispose required to prevent memory leak.
                        healthMsg.Dispose();
                    }
                    i++;
                }
            }
            catch (KException ex)
            {
                Console.WriteLine("Error: {0}", ex.Status);
            }

            // wait for Enter key
            Console.WriteLine("\nPress ENTER to continue");
            do
            {
                System.Threading.Thread.Sleep(100);
            } while (Console.Read() != (int)ConsoleKey.Enter);
            return(1);
        }