Esempio n. 1
0
        /// <summary>
        /// devname device name
        /// </summary>
        /// <param name="DevName"></param>
        public void DownloadZaudioFrmDeviceToBuf(string DevName, int PageIndex, int DeviceType)
        {
            string strMainRemark = DevName.Split('\\')[1].Trim();
            String TmpDevName    = DevName.Split('\\')[0].Trim();

            //保存basic informations网络信息
            byte SubNetID = byte.Parse(TmpDevName.Split('-')[0].ToString());
            byte DeviceID = byte.Parse(TmpDevName.Split('-')[1].ToString());

            byte[] ArayTmp = null;

            String TmpRemark = HDLSysPF.ReadDeviceMainRemark(SubNetID, DeviceID);

            DeviceName = SubNetID.ToString() + "-" + DeviceID.ToString() + "\\" + TmpRemark;

            if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy)
            {
                CsConst.calculationWorker.ReportProgress(10);
            }
            if (PageIndex == 0 || PageIndex == 1)
            {
                if (netWork == null)
                {
                    netWork = new NetworkInformation();
                }
                netWork.readNetworkInfomation(SubNetID, DeviceID);
                #region
                if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x3007, SubNetID, DeviceID, false, true, true, false) == true)
                {
                    bytWorkType = CsConst.myRevBuf[25];

                    byte[] arayRemark = new byte[20];
                    for (int intI = 0; intI < 20; intI++)
                    {
                        arayRemark[intI] = CsConst.myRevBuf[26 + intI];
                    }
                    strGroup = HDLPF.Byte2String(arayRemark);
                    if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy)
                    {
                        CsConst.calculationWorker.ReportProgress(20);
                    }
                    arayRemark = new byte[20];
                    for (int intI = 0; intI < 20; intI++)
                    {
                        arayRemark[intI] = CsConst.myRevBuf[46 + intI];
                    }
                    strPrjName = HDLPF.Byte2String(arayRemark);
                    if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy)
                    {
                        CsConst.calculationWorker.ReportProgress(30);
                    }
                    arayRemark = new byte[8];
                    for (int intI = 0; intI < 8; intI++)
                    {
                        arayRemark[intI] = CsConst.myRevBuf[66 + intI];
                    }
                    strUser = HDLPF.Byte2String(arayRemark);

                    arayRemark = new byte[8];
                    for (int intI = 0; intI < 8; intI++)
                    {
                        arayRemark[intI] = CsConst.myRevBuf[74 + intI];
                    }
                    strPWD           = HDLPF.Byte2String(arayRemark);
                    CsConst.myRevBuf = new byte[1200];
                    if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy)
                    {
                        CsConst.calculationWorker.ReportProgress(40);
                    }
                }
                else
                {
                    return;
                }

                if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x3009, SubNetID, DeviceID, false, true, true, false) == true)
                {
                    strServer1 = CsConst.myRevBuf[25].ToString("d3") + "." + CsConst.myRevBuf[26].ToString("d3")
                                 + "." + CsConst.myRevBuf[27].ToString("d3") + "." + CsConst.myRevBuf[28].ToString("d3");
                    intPort1 = CsConst.myRevBuf[29] * 256 + CsConst.myRevBuf[30];

                    strServer2 = CsConst.myRevBuf[31].ToString("d3") + "." + CsConst.myRevBuf[32].ToString("d3")
                                 + "." + CsConst.myRevBuf[33].ToString("d3") + "." + CsConst.myRevBuf[34].ToString("d3");
                    intPort2 = CsConst.myRevBuf[35] * 256 + CsConst.myRevBuf[36];

                    bytEnDHCP        = CsConst.myRevBuf[37];
                    bytTimer         = CsConst.myRevBuf[38];
                    CsConst.myRevBuf = new byte[1200];
                }
                else
                {
                    return;
                }
                if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy)
                {
                    CsConst.calculationWorker.ReportProgress(50);
                }
                #endregion
                MyRead2UpFlags[0] = true;
            }

            if (PageIndex == 0 || PageIndex == 2)
            {
                if (!IPmoduleDeviceTypeList.IpModuleV3TimeZoneUrl.Contains(DeviceType)) //bus版不支持子网过滤
                {
                    if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x1D46, SubNetID, DeviceID, false, true, true, false) == true)
                    {
                        isEnable   = CsConst.myRevBuf[25];
                        bytPassSub = CsConst.myRevBuf[26];
                    }
                }
                //读取拦截列表
                #region
                MyBlocks = new List <RFBlock>();
                for (byte bytI = 0; bytI < 16; bytI++)
                {
                    RFBlock Tmp = new RFBlock();
                    if (Tmp.ReadRfBlockSetupInformation(SubNetID, DeviceID, bytI) == true)
                    {
                        MyBlocks.Add(Tmp);
                    }
                    else
                    {
                        return;
                    }
                    if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy)
                    {
                        CsConst.calculationWorker.ReportProgress(50 + bytI);
                    }
                }
                #endregion
                MyRead2UpFlags[1] = true;
            }

            //下载无线遥控器地址
            if (PageIndex == 0 || PageIndex == 3)
            {
                Byte[] RemoteAddress = new Byte[11];
                MyRemoteControllers = new HDLButton[48 * 4];
                if (CsConst.mySends.AddBufToSndList(ArayTmp, 0xE010, SubNetID, DeviceID, false, true, true, false) == true)
                {
                    Array.Copy(CsConst.myRevBuf, 28, RemoteControllers, 0, 8);
                    RemoteControllers.CopyTo(RemoteAddress, 3);
                }

                Byte ValidRemoteNumber = 4;
                //判断地址是不是全部一样 一样保存一个即可
                if (((RemoteAddress[3] == RemoteAddress[5]) && (RemoteAddress[5] == RemoteAddress[7]) && (RemoteAddress[7] == RemoteAddress[9])) &&
                    ((RemoteAddress[4] == RemoteAddress[6]) && (RemoteAddress[6] == RemoteAddress[8]) && (RemoteAddress[8] == RemoteAddress[10])))
                {
                    ValidRemoteNumber = 1;
                }

                //测试按键是不是支持目标有效无效的读取
                Boolean blnIsSupportE474 = false;
                blnIsSupportE474 = CsConst.mySends.AddBufToSndList(ArayTmp, 0xE474, SubNetID, DeviceID, false, false, true, false);

                for (Byte i = 0; i < ValidRemoteNumber; i++)
                {
                    //无效地址不保存
                    if (RemoteAddress[3 + i * 2] == 0 && RemoteAddress[4 + i * 2] == 0)
                    {
                        continue;
                    }
                    if (RemoteAddress[3 + i * 2] == 255 && RemoteAddress[4 + i * 2] == 255)
                    {
                        continue;
                    }
                    //读取模式是否有效
                    Byte[] arayKeyMode   = new byte[IPmoduleDeviceTypeList.HowManyButtonsEachPage]; //按键模式
                    Byte[] arayKeyDimmer = new byte[IPmoduleDeviceTypeList.HowManyButtonsEachPage]; // 要不要调光,要不要保存调光

                    arayKeyMode   = ReadButtonModeFrmDeviceToBuf(i, SubNetID, DeviceID);
                    arayKeyDimmer = ReadButtonDimFlagFrmDeviceToBuf(i, SubNetID, DeviceID);

                    if (arayKeyMode == null)
                    {
                        return;
                    }

                    for (int j = 0; j < 48; j++)
                    {
                        HDLButton oKey = MyRemoteControllers[IPmoduleDeviceTypeList.HowManyButtonsEachPage * i + j];
                        oKey            = new HDLButton();
                        oKey.ID         = Convert.ToByte(j + 1);
                        oKey.Mode       = arayKeyMode[j];
                        oKey.IsDimmer   = (Byte)(arayKeyDimmer[j] >> 4);
                        oKey.SaveDimmer = (Byte)(arayKeyDimmer[j] & 0x01);

                        oKey.ReadButtonRemarkAndCMDFromDevice(SubNetID, DeviceID, DeviceType, i, 255, blnIsSupportE474, 0, 0);
                        if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy)
                        {
                            CsConst.calculationWorker.ReportProgress(60 + j / 2);
                        }
                        MyRemoteControllers[IPmoduleDeviceTypeList.HowManyButtonsEachPage * i + j] = oKey;
                    }
                }
            }
            if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy)
            {
                CsConst.calculationWorker.ReportProgress(100);
            }
        }