Example #1
0
        public static YSensorProxy FindSensor(string name)
        {
            // cases to handle:
            // name =""  no matching unknwn
            // name =""  unknown exists
            // name != "" no  matching unknown
            // name !="" unknown exists
            YSensor      func = null;
            YSensorProxy res  = (YSensorProxy)YFunctionProxy.FindSimilarUnknownFunction("YSensorProxy");

            if (name == "")
            {
                if (res != null)
                {
                    return(res);
                }
                res = (YSensorProxy)YFunctionProxy.FindSimilarKnownFunction("YSensorProxy");
                if (res != null)
                {
                    return(res);
                }
                func = YSensor.FirstSensor();
                if (func != null)
                {
                    name = func.get_hardwareId();
                    if (func.get_userData() != null)
                    {
                        return((YSensorProxy)func.get_userData());
                    }
                }
            }
            else
            {
                func = YSensor.FindSensor(name);
                if (func.get_userData() != null)
                {
                    return((YSensorProxy)func.get_userData());
                }
            }
            if (res == null)
            {
                res = new YSensorProxy(func, name);
            }
            if (func != null)
            {
                res.linkToHardware(name);
                if (func.isOnline())
                {
                    res.arrival();
                }
            }
            return(res);
        }
Example #2
0
 async Task sensorTimedReportCallBack(YSensor fct, YMeasure measure)
 {
     Output.Text += await fct.get_hardwareId() + ": " + measure.get_averageValue() + " " + await fct.get_userData() + " (timed report)\n";
 }
Example #3
0
 static void sensorTimedReportCallBack(YSensor fct, YMeasure measure)
 {
     Console.WriteLine(fct.get_hardwareId() + ": " + measure.get_averageValue() + " " + fct.get_userData() + " (timed report)");
 }
Example #4
0
 async Task sensorValueChangeCallBack(YSensor fct, string value)
 {
     Output.Text += await fct.get_hardwareId() + ": " + value + " " + await fct.get_userData() + " (new value)\n";
 }
Example #5
0
 static void sensorValueChangeCallBack(YSensor fct, string value)
 {
     Console.WriteLine(fct.get_hardwareId() + ": " + value + " " + fct.get_userData() + " (new value)");
 }