コード例 #1
0
    public List <Sensor> get_sensor_list(int device_index, int sensor_class)
    {
        int    sensor_index;
        int    NbSensors;
        bool   result;
        int    sensor_id  = 0;
        string sensorname = "";
        int    iValue     = 0;
        float  fValue     = 0;
        float  fMinValue  = 0;
        float  fMaxValue  = 0;
        var    sensors    = new List <Sensor>();

        NbSensors = pSDK.GetNumberOfSensors(device_index, sensor_class);
        for (sensor_index = 0; sensor_index < NbSensors; sensor_index += 1)
        {
            result = pSDK.GetSensorInfos(device_index,
                                         sensor_index,
                                         sensor_class,
                                         ref sensor_id,
                                         ref sensorname,
                                         ref iValue,
                                         ref fValue,
                                         ref fMinValue,
                                         ref fMaxValue);
            if (result == true)
            {
                var data = new Sensor();
                data.name  = sensorname;
                data.value = Math.Round(fValue, 2);
                sensors.Add(data);
            }
        }
        return(sensors);
    }