示例#1
0
    void checkForRobots()
    {
        variables = robotMessages.GetVariables();
        if (variables.ContainsKey("devices") && !gotDevices)
        {
            //Debug.Log("got devices");
            devices = new List <IDictionary <string, string> >();
            //Debug.Log(variables["devices"]);
            deviceList = JSON.Parse(variables["devices"]);
            if (deviceList.Count != countDevices)
            {
                cLog        += ("There are ") + deviceList.Count + (" devices connected \n");
                countDevices = deviceList.Count;
            }

            if (deviceList.Count != 0)
            {
                printR = ("");
                for (int i = 0; i < deviceList.Count; i++)
                {
                    //Debug.Log("got device");
                    //Debug.Log (deviceList[i]);
                    //new Dictionary<string, string>(variables);
                    var device = new Dictionary <string, string>();
                    device["internalIp"] = deviceList[i]["internalIp"];
                    device["botVersion"] = deviceList[i]["botVersion"];
                    device["last"]       = deviceList[i]["last"];
                    device["mac"]        = deviceList[i]["mac"];
                    device["shortName"]  = deviceList[i]["shortName"];
                    Debug.Log(device);
                    devices.Add(device);
                    //devicesList[i].internalIp

                    gotDevices = true;
                    printR    += "Robots Found... Getting Info \n";
                    printR    += devices[i]["shortName"] + ("\n");
                    printR    += ("IP: ") + devices[i]["internalIp"] + ("\n \n");
                }
            }
            else
            {
                cLog  += "No robots found, still looking... \n";
                printR = "No robots found";
            }
        }
        robotSelector();
    }