Exemplo n.º 1
0
        private static (string templateStr, bool oldTemplate) CmdJSONString(string pluginUUID, string miningLocation, string username, params string[] uuids)
        {
            var templatePath          = CmdConfig.CommandFileTemplatePath(pluginUUID);
            var miningServiceLocation = GetServiceLocation(miningLocation);
            var str = CmdConfig.CreateCommandFileWithTemplate(miningServiceLocation, username, uuids, templatePath);

            if (str != null)
            {
                return(str, false);
            }
            const string DEVICE         = @"		{""id"":3,""method"":""worker.add"",""params"":[""daggerhashimoto"",""_DEV_ID_""]}";
            const string TEMPLATE       = @"
[
	{""time"":0,""commands"":[
		{""id"":1,""method"":""subscribe"",""params"":[""_MINING_SERVICE_LOCATION_"",""_PUT_YOUR_BTC_HERE_""]}
	]},
	{""time"":1,""commands"":[
        {""id"":1,""method"":""algorithm.add"",""params"":[""daggerhashimoto""]}
    ]},
	{""time"":2,""commands"":[
_DEVICES_
	]}
]";
            var          devices        = string.Join(",\n", uuids.Select(uuid => DEVICE.Replace("_DEV_ID_", uuid)));
            var          oldTemplateStr = TEMPLATE
                                          .Replace("_MINING_SERVICE_LOCATION_", miningServiceLocation)
                                          .Replace("_PUT_YOUR_BTC_HERE_", username)
                                          .Replace("_DEVICES_", devices);

            return(oldTemplateStr, true);
        }
        public List <DEVICE> DanhSachThietBiCuaNguoiDung(string IDUser)
        {
            AGRIBOTSYSTEMDataContext context       = new AGRIBOTSYSTEMDataContext();
            List <USR_DV>            lstUserDevice = context.USR_DVs
                                                     .Where(x => x.IDUSR == IDUser)
                                                     .ToList();

            var list = new List <USR_DV>();

            foreach (var e in lstUserDevice)
            {
                list.Add(new USR_DV
                {
                    IDDV  = e.IDDV,
                    IDUSR = e.IDUSR
                });
            }

            List <DEVICE> lstDevice = new List <DEVICE>();

            foreach (var item in list)
            {
                DEVICE dv = context.DEVICEs.FirstOrDefault(x => x.ID == item.IDDV);
                dv.USR_DVs = null;
                dv.DVSSes  = null;
                dv.DVMTs   = null;


                lstDevice.Add(dv);
            }
            return(lstDevice);
        }
Exemplo n.º 3
0
        private static string CmdJSONString(string miningLocation, string username, params string[] uuids)
        {
            const string DEVICE   = @"		{""id"":3,""method"":""worker.add"",""params"":[""daggerhashimoto"",""_DEV_ID_""]}";
            const string TEMPLATE = @"
[
	{""time"":0,""commands"":[
		{""id"":1,""method"":""subscribe"",""params"":[""nhmp._MINING_LOCATION_.nicehash.com:3200"",""_PUT_YOUR_BTC_HERE_""]}
	]},
	{""time"":1,""commands"":[
        {""id"":1,""method"":""algorithm.add"",""params"":[""daggerhashimoto""]}
    ]},
	{""time"":2,""commands"":[
_DEVICES_
	]},
	{""time"":10,""commands"":[
		{""id"":1,""method"":""worker.reset"",""params"":[""0""]}
	]},
	{""time"":15,""loop"":15,""commands"":[
		{""id"":1,""method"":""algorithm.print.speeds"",""params"":[]},
		{""id"":1,""method"":""worker.reset"",""params"":[""0""]}
	]}
]";
            var          devices  = string.Join(",\n", uuids.Select(uuid => DEVICE.Replace("_DEV_ID_", uuid)));

            return(TEMPLATE
                   .Replace("_MINING_LOCATION_", miningLocation)
                   .Replace("_PUT_YOUR_BTC_HERE_", username)
                   .Replace("_DEVICES_", devices));
        }
Exemplo n.º 4
0
        /// <summary>
        /// retrieve device list, use first in the list for further communication
        /// </summary>
        /// <returns></returns>

        public void GetDevList()
        {
            int devcount = 10; //size of array

            deviceList.Clear();

            //pointer to memory cell storing actual device array size returned from dll proc
            IntPtr ptcount = Marshal.AllocHGlobal(Marshal.SizeOf(devcount));

            Marshal.WriteInt32(ptcount, devcount);

            int bres = GetDeviceList(udevices, ptcount, null, 0, 2);

            //found devices count
            devcount = Marshal.ReadInt32(ptcount);

            //if all ok, and devices count > 0, use first device in the array for further communication
            if (bres == 0)
            {
                Console.WriteLine("Error occured");
            }

            if (bres > 0 && devcount > 0)
            {
                Device = new DEVICE();
                Device = (DEVICE)Marshal.PtrToStructure(udevices[0], typeof(DEVICE));

                // add device to the device list
                deviceClass d = new deviceClass();
                d.device    = Device;
                d.devicePtr = udevices[0];
                deviceList.Add(d);

                switch ((DeviceType)Device.m_DeviceType)
                {
                case DeviceType.DT_PWM_USB:
                case DeviceType.DT_PWML_USB:
                case DeviceType.DT_PWM_LAN:
                    Console.WriteLine(String.Format("Total devices found {0}. Communicating with PWM device\n", devcount));
                    break;

                case DeviceType.DT_PMS_USB:
                case DeviceType.DT_PMS_LAN:
                case DeviceType.DT_PMS_WLAN:
                case DeviceType.DT_PMS2_LAN:
                case DeviceType.DT_PMS2_WLAN:
                    Console.WriteLine(String.Format("Total devices found {0}. Communicating with PMS device\n", devcount));
                    break;

                default:
                    Console.WriteLine(String.Format("Total devices found {0}. Unknown device found\n", devcount));
                    break;
                }
            }
            else
            {
                Console.WriteLine(String.Format("No device found\n"));
            }
        }
Exemplo n.º 5
0
    //对外获取设备的方法
    public SteamVR_Controller.Device GetDevice(DEVICE device)
    {
        switch (device)
        {
        case DEVICE.LEFT: Cur_device = SteamVR_Controller.Input((int)leftHand.index);   break;

        case DEVICE.RIGHT: Cur_device = SteamVR_Controller.Input((int)rightHand.index); break;
        }
        return(Cur_device);
    }
Exemplo n.º 6
0
        public Giohang(int Masach, string Machitiet)
        {
            this.iMasach = Masach;
            DEVICE sach = db.DEVICEs.SingleOrDefault(n => n.MaDevice == Masach);

            this.sTensach = sach.TenDevice;
            this.sAnhbia  = sach.AnhBia;
            this.dDongia  = double.Parse(sach.GiaBan.ToString());
            this.iSoluong = 1;

            this.chitiet = db.Sheet1_s.SingleOrDefault(n => n.MaChiTiet == Machitiet);
        }
Exemplo n.º 7
0
        public ActionResult Edit(int id)
        {
            DEVICE dev = db.DEVICEs.SingleOrDefault(n => n.MaDevice == id);

            if (dev == null)
            {
                Response.StatusCode = 404;
                return(null);
            }
            ViewBag.MaCD  = new SelectList(db.CHU_DEs.ToList().OrderBy(n => n.TenChuDe), "MaCD", "TenChuDe");
            ViewBag.MaNSX = new SelectList(db.NHA_SAN_XUATs.ToList().OrderBy(n => n.TenNSX), "MaNSX", "TenNSX");
            return(View(dev));
        }
Exemplo n.º 8
0
        public ActionResult Delete(int id)
        {
            DEVICE dev = db.DEVICEs.SingleOrDefault(n => n.MaDevice == id);

            if (dev == null)
            {
                Response.StatusCode = 404;
                return(null);
            }
            db.DEVICEs.DeleteOnSubmit(dev);
            db.SubmitChanges();
            return(RedirectToAction("device"));
        }
Exemplo n.º 9
0
        public override string ToString()
        {
            OperatingSystem os   = System.Environment.OSVersion;
            Version         v    = System.Environment.Version;
            string          wote = "dev: " + DEVICE.ToString() +
                                   "\r\nos: " + OS.ToString() +
                                   "\r\nclr: " + CLR.ToString() +
                                   "\r\n" +
                                   "\r\nplat: " + System.Environment.OSVersion.Platform.ToString() +
                                   "\r\nos: " + System.Environment.OSVersion.ToString() +
                                   "\r\nver:" + System.Environment.Version.ToString();

            return(wote);
        }
Exemplo n.º 10
0
        public DEVICE SearchIDs(string ID)
        {
            AGRIBOTSYSTEMDataContext context = new AGRIBOTSYSTEMDataContext();
            DEVICE device = context.DEVICEs.FirstOrDefault(x => x.ID == ID);

            USR_DV usr_dv = context.USR_DVs.FirstOrDefault(x => x.IDDV == device.ID);

            if (usr_dv != null)
            {
                device.ID = null;
            }

            return(device);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Registrando/Verificando registro de dispositivo
        /// </summary>
        /// <param name="uuid"></param>
        /// <returns></returns>
        public string GetVerifyuuid(string uuid)
        {
            var device = db.DEVICE.Where(p => p.uuid == uuid).FirstOrDefault();
            string action = "Device registrado";
            if (device == null)
            {
                var newdevice = new DEVICE();
                newdevice.dateRegistro = DateTime.Now;
                newdevice.uuid = uuid;
                db.DEVICE.Add(newdevice);
                db.SaveChanges();
                action = "Novo Device registrado";
            }

            return action;
        }
Exemplo n.º 12
0
        /// <summary>
        /// Registrando/Verificando registro de dispositivo
        /// </summary>
        /// <param name="uuid"></param>
        /// <returns></returns>
        public string GetVerifyuuid(string uuid)
        {
            var    device = db.DEVICE.Where(p => p.uuid == uuid).FirstOrDefault();
            string action = "Device registrado";

            if (device == null)
            {
                var newdevice = new DEVICE();
                newdevice.dateRegistro = DateTime.Now;
                newdevice.uuid         = uuid;
                db.DEVICE.Add(newdevice);
                db.SaveChanges();
                action = "Novo Device registrado";
            }

            return(action);
        }
Exemplo n.º 13
0
        public bool UpdateStatus(string ID, int status)
        {
            try
            {
                AGRIBOTSYSTEMDataContext context = new AGRIBOTSYSTEMDataContext();


                DEVICE dv = context.DEVICEs.FirstOrDefault(x => x.ID == ID);

                if (dv != null)
                {
                    dv.STATUS = status;
                    context.SubmitChanges();
                    return(true);
                }
            }
            catch { }
            return(false);
        }
Exemplo n.º 14
0
 public bool LuuDevice(string id, string partcode, string name, int status)
 {
     try
     {
         AGRIBOTSYSTEMDataContext context = new AGRIBOTSYSTEMDataContext();
         DEVICE dv = new DEVICE();
         dv.ID       = id;
         dv.NAME     = name;
         dv.STATUS   = status;
         dv.PARTCODE = partcode;
         context.DEVICEs.InsertOnSubmit(dv);
         context.SubmitChanges();
         return(true);
     }
     catch
     {
     }
     return(false);
 }
Exemplo n.º 15
0
        /// <summary>
        /// Obtains a list of all present (active and inactive) devices
        /// </summary>
        /// <returns>Returns an array of <see cref="DEVICE"/>s</returns>
        public static DEVICE[] GetAllPresentDevices()
        {
            var devices = new List <DEVICE>();
            var guid    = new Guid();
            var handle  = SETUPAPI.SetupDiGetClassDevs(ref guid, null, IntPtr.Zero, DIGCF.ALLCLASSES | DIGCF.PRESENT);

            if (handle.IsInvalid)
            {
                throw new Win32ErrorException();
            }
            var info = new SP_DEVINFO_DATA();

            info.cbSize = (uint)Marshal.SizeOf(info);
            for (uint i = 0; SETUPAPI.SetupDiEnumDeviceInfo(handle, i, ref info); i++)
            {
                var device = new DEVICE(handle, info);
                devices.Add(device);
            }
            return(devices.ToArray());
        }
Exemplo n.º 16
0
        public ActionResult Edit(DEVICE dev, HttpPostedFileBase fileUpload)
        {
            ViewBag.MaCD  = new SelectList(db.CHU_DEs.ToList().OrderBy(n => n.TenChuDe), "MaCD", "TenChuDe");
            ViewBag.MaNSX = new SelectList(db.NHA_SAN_XUATs.ToList().OrderBy(n => n.TenNSX), "MaNSX", "TenNSX");
            DEVICE devS = db.DEVICEs.Single(n => n.MaDevice == dev.MaDevice);

            if (ModelState.IsValid)
            {
                if (fileUpload != null)
                {
                    //luu ten file
                    var fileName = Path.GetFileName(fileUpload.FileName);
                    //luu duong dan file
                    var path = Path.Combine(Server.MapPath("~/image/DEVICE"), fileName);
                    //kiem tra file ton tai chu
                    if (System.IO.File.Exists(path))
                    {
                        ViewBag.thongbao = "hình ảnh đã tồn tại";
                    }
                    else
                    {
                        fileUpload.SaveAs(path);
                    }
                    dev.AnhBia = fileName;
                }
                else
                {
                    dev.AnhBia = devS.AnhBia;
                }



                db.DEVICEs.DeleteOnSubmit(devS);
                db.DEVICEs.InsertOnSubmit(dev);
                db.SubmitChanges();
            }

            return(RedirectToAction("device"));
        }
Exemplo n.º 17
0
        public ActionResult CreatNew(DEVICE dev, HttpPostedFileBase fileUpload)
        {
            ViewBag.MaCD  = new SelectList(db.CHU_DEs.ToList().OrderBy(n => n.TenChuDe), "MaCD", "TenChuDe");
            ViewBag.MaNSX = new SelectList(db.NHA_SAN_XUATs.ToList().OrderBy(n => n.TenNSX), "MaNSX", "TenNSX");

            if (fileUpload == null)
            {
                ViewBag.thongbao = "vui lòng chọn hình ảnh";
                return(View());
            }
            else
            {
                if (ModelState.IsValid)
                {
                    //luu ten file
                    var fileName = Path.GetFileName(fileUpload.FileName);
                    //luu duong dan file
                    var path = Path.Combine(Server.MapPath("~/image/DEVICE"), fileName);
                    //kiem tra file ton tai chu
                    if (System.IO.File.Exists(path))
                    {
                        ViewBag.thongbao = "hình ảnh đã tồn tại";
                    }
                    else
                    {
                        fileUpload.SaveAs(path);
                    }

                    dev.AnhBia = fileName;
                    db.DEVICEs.InsertOnSubmit(dev);
                    db.SubmitChanges();
                }

                return(View());
            }
        }
Exemplo n.º 18
0
 public static extern int WSEnumDevices(IntPtr lpws, ref DEVICE lpDevice, WSEnumDevicesCallback callback);
Exemplo n.º 19
0
    // UpdateDeviceDetectionMsgCallback
    void UpdateDeviceDetectionMsgCallback(DEVICE device, bool attached)
    {
        if (attached == true)
        {
            switch (device)
            {
                case (DEVICE.HMDSensor):
                    strDeviceDetection = "HMD SENSOR ATTACHED";
                    break;

                case (DEVICE.HMD):
                    strDeviceDetection = "HMD ATTACHED";
                    break;

                case (DEVICE.LatencyTester):
                    strDeviceDetection = "LATENCY SENSOR ATTACHED";
                    break;
            }
        }
        else
        {
            switch (device)
            {
                case (DEVICE.HMDSensor):
                    strDeviceDetection = "HMD SENSOR DETACHED";
                    break;

                case (DEVICE.HMD):
                    strDeviceDetection = "HMD DETACHED";
                    break;

                case (DEVICE.LatencyTester):
                    strDeviceDetection = "LATENCY SENSOR DETACHED";
                    break;
            }
        }
    }
Exemplo n.º 20
0
 public static extern int WSEnumDevices(IntPtr lpws, ref DEVICE lpDevice, WSEnumDevicesCallback callback);
Exemplo n.º 21
0
        //对相关设备进行相关操作
        public bool Operate(OPERATE Operate, DEVICE Device, ref bool State, ref int Value, ref int[] Config, ref string erro)
        {
            RequestFormat  request = new RequestFormat(); //将请求封装成Socket请求信息
            ResponseFormat response;                      //Socket响应信息用于接受响应消息
            int            value = Value;                 //用于暂时存放参数Value值,Value值即可能是传进参数又可能是传出参数
            bool           state = State;                 //用于暂时存放参数State值,State值即可能是传进参数又可能是传出参数

            int[] config = Config;                        //用于暂时存放参数Config值,Config值即可能是传进参数又可能是传出参数
            Config          = null;
            request.FunCode = (byte)((int)Operate);
            request.Device  = (byte)((int)Device);
            switch (Operate)           //根据操作,用相应的参数对request进行封装
            {
            case OPERATE.MODIFY_STATE: //该操作为更改开关状态操作,参数State表示请求打开还是关闭
            {
                if (Device == DEVICE.VEDIO)
                {
                    request.State = state;
                    request.Value = value;
                }
                else if (Device == DEVICE.CAMERA)
                {
                    request.State     = state;
                    request.Value     = value;
                    request.Config    = new int[config.Length + 1];
                    request.Config[0] = config.Length;
                    int j = 1;
                    foreach (int i in config)
                    {
                        request.Config[j] = i;
                        j++;
                    }
                }
                else
                {
                    erro += "你选择的设备不能进行更改开关状态操作!";
                    return(false);
                }
                break;
            }

            case OPERATE.QUERY_PARAM:    //该操作为查询操作,根据Value来判断,如何Value为0说明是查状态,如何Value为1说明是查参数,如何Value为2说明是查配置信息
            {
                request.Value = value;   //需要做出是否合理的判断
                break;
            }

            case OPERATE.ADJUST_PARAM:       //该操作为调节参数操作
            {
                if (Device == DEVICE.FILTER) //调节空调操作,参数为State
                {
                    if (state == true)
                    {
                        request.Value = value;
                    }
                    else
                    {
                        request.Value = -1;
                    }
                }
                else if (Device == DEVICE.VEDIO)
                {
                    request.State     = state;
                    request.Value     = value;
                    request.Config    = new int[config.Length + 1];
                    request.Config[0] = config.Length;
                    int j = 1;
                    foreach (int i in config)
                    {
                        request.Config[j] = i;
                        j++;
                    }
                }
                else
                {
                    erro += "你选择的设备不能进行调节参数操作!";
                    return(false);
                }
                break;
            }

            case OPERATE.CONFIG_PARAM:    //该操作为配置操作
            {
                if (config == null)
                {
                    erro += "配置操作时,传入参数出错!";
                    return(false);
                }
                if (Device == DEVICE.ALL)              //全局配置
                {
                    if (config.Length != ConfigAllNum) //全局配置时,传入参数只有一个
                    {
                        erro += "全局配置时,传入参数出错!";
                        return(false);
                    }
                    else
                    {
                        request.Config    = new int[config.Length + 1];
                        request.Config[0] = config.Length;
                        int j = 1;
                        foreach (int i in config)
                        {
                            request.Config[j] = i;
                            j++;
                        }
                    }
                }
                else
                {
                    if (Device == DEVICE.VEDIO || Device == DEVICE.FILTER)
                    {
                        if (config.Length != 1)        //单一配置时,传入参数只有一个
                        {
                            erro += "视频与滤片配置,传入参数出错!";
                            return(false);
                        }
                        else
                        {
                            request.Value = config[0];
                        }
                    }
                    else
                    {
                        erro += "你选择的设备不能进行配置操作!";
                        return(false);
                    }
                }
                break;
            }

            default:
            {
                erro += "选择的操作有误!";
                return(false);
            }
            }

            int ret = SendAnAcceptControlMsg(request, ref erro, out response);//发送请求消息和接受响应消息

            if (ret == -1 && ret == 4)
            {
                erro += "Socket传输错误!";
                return(false);//出错
            }
            else
            {
                if (response.IsSucceed == true)//该操作成功
                {
                    erro = Encoding.ASCII.GetString(response.Info);
                    switch (Operate)
                    {
                    case OPERATE.MODIFY_STATE:    //该操作为更改开关状态操作
                    {
                        if (Device == DEVICE.CAMERA || Device == DEVICE.VEDIO)
                        {
                            Value = response.Value;
                        }
                        return(true);
                    }

                    case OPERATE.QUERY_PARAM:  //该操作为查询参数操作
                    {
                        if (value == 0)        //查询设备状态
                        {
                            if (response.Value == 1)
                            {
                                State = true;
                            }
                            else
                            {
                                State = false;
                            }
                            return(true);
                        }
                        else if (value == 1)        //查询设备参数
                        {
                            if (Device == DEVICE.CAMERA)
                            {
                                if (response.Config == null || response.Config[0] != 6)        //全局查询配置时,返回值有8个
                                {
                                    erro += "查询图像采集配置时,返回值有误!";
                                    return(false);
                                }
                                else
                                {
                                    Config = new int[6];
                                    int j = 0;
                                    for (int i = 1; i < 6; i++)
                                    {
                                        Config[j] = response.Config[i];
                                        j++;
                                    }
                                    return(true);
                                }
                            }
                            else if (Device == DEVICE.VEDIO)
                            {
                                if (response.Config == null || response.Config[0] != 6)        //全局查询配置时,返回值有8个
                                {
                                    erro += "查询视频采集配置时,返回值有误!";
                                    return(false);
                                }
                                else
                                {
                                    Config = new int[6];
                                    int j = 0;
                                    for (int i = 1; i < 6; i++)
                                    {
                                        Config[j] = response.Config[i];
                                        j++;
                                    }
                                    return(true);
                                }
                            }
                            else if (Device == DEVICE.FILTER)
                            {
                                Value = response.Value;
                            }
                            return(true);
                        }
                        else if (value == 2)        //查询全局配置信息操作
                        {
                            if (Device == DEVICE.ALL)
                            {
                                if (response.Config == null || response.Config[0] != 16)        //全局查询配置时,返回值有8个
                                {
                                    erro += "全局查询配置信息时,返回值有误!";
                                    return(false);
                                }
                                else
                                {
                                    Config = new int[16];
                                    int j = 0;
                                    for (int i = 1; i < 16; i++)
                                    {
                                        Config[j] = response.Config[i];
                                        j++;
                                    }
                                    return(true);
                                }
                            }
                            else
                            {
                                Config    = new int[1];
                                Config[0] = response.Value;
                                return(true);
                            }
                        }
                        else
                        {
                            erro += "查询操作时,传出的Value标志有误!";
                            return(false);
                        }
                    }

                    case OPERATE.ADJUST_PARAM:    //该操作为调节参数操作
                    {
                        Value = response.Value;
                        return(true);
                    }

                    case OPERATE.CONFIG_PARAM:    //该操作为配置操作
                    {
                        return(true);
                    }

                    default:
                    {
                        erro += "!@#$%^&*()";
                        return(false);
                    }
                    }
                }
                else//该操不成功
                {
                    if (response.Info == null)
                    {
                        erro += "板子崩毁!";
                    }
                    else
                    {
                        erro = Encoding.ASCII.GetString(response.Info);
                    }
                    return(false);
                }
            }
        }
Exemplo n.º 22
0
    // Use this for initialization
    void Start()
    {
        //This be the default?
        if (GameObjectTracker.instance == null)
        {
            Debug.LogError("NO GOT!!");
        }


        //DeviceControlsStartIndex = DEVICE.iphone;
        //GameObjectTracker.instance._PlayerData.currentDevice = DEVICE.iphone;



#if UNITY_IPHONE
        if (Application.platform == RuntimePlatform.IPhonePlayer)
        {
            //Check the device and assign the index.
            if ((iPhone.generation == iPhoneGeneration.iPad2Gen) ||
                (iPhone.generation == iPhoneGeneration.iPad3Gen) ||
                (iPhone.generation == iPhoneGeneration.iPad4Gen))
            {
                DeviceControlsStartIndex = DEVICE.iPad;

                //let the player data know waht device we have
                GameObjectTracker.instance._PlayerData.currentDevice = DEVICE.iPad;
            }
            else
            {
                DeviceControlsStartIndex = DEVICE.iphone;

                if (iPhone.generation == iPhoneGeneration.iPhone4S ||
                    iPhone.generation == iPhoneGeneration.iPodTouch5Gen)
                {
                    QualitySettings.SetQualityLevel(0, true);
                }

                //let the player data know waht device we have
                GameObjectTracker.instance._PlayerData.currentDevice = DEVICE.iphone;
            }
        }
#endif



        // start the current Device controls index to the starting index.
        currentDeviceControlsIndex = DeviceControlsStartIndex;

        //Then based on the current device index we load the prefab for the device.

        // we going to instantiate with the ngui tools because it needs to be correctly
        // inserted below us.
        if (loadAtStart)
        {
            if (controlsLayoutPrefabs.Length > (int)currentDeviceControlsIndex)
            {
                ControlsLayoutObject loadPrefab = controlsLayoutPrefabs[(int)currentDeviceControlsIndex];
                if (loadPrefab)                  // we have a prefab to load

                {
                    loadedObject = NGUITools.AddChild(this.gameObject, loadPrefab.gameObject).GetComponent <ControlsLayoutObject>();
                    if (loadedObject)
                    {
//						Debug.Log("We have a controls Layout Object " + loadedObject.name);
                    }
                }
            }
            else              // we're out of bounds, load the default or nothing
            {
                if (defaultControlsLayout != null)
                {
                    loadedObject = NGUITools.AddChild(this.gameObject, defaultControlsLayout.gameObject).GetComponent <ControlsLayoutObject>();
                    if (loadedObject)
                    {
                        Debug.LogWarning("Loaded Default Controls Layout Object " + loadedObject.name);
                    }
                }
            }
        }
    }