| | |
| | | /// <param name="i_listdevice">窗帘的回路</param>
|
| | | public void ShowForm(Rollershade i_CurtainDevice)
|
| | | {
|
| | | UserView.HomePage.Instance.ScrollEnabled = false;
|
| | | this.ScrollEnabled = false;
|
| | |
|
| | | this.curtainDevice = i_CurtainDevice;
|
| | |
|
| | |
| | | listView.Height = bodyFrameLayout.Height;
|
| | | bodyFrameLayout.AddChidren(listView);
|
| | |
|
| | | //添加方向行
|
| | | this.AddDirectionRow();
|
| | | //添加限位行
|
| | | this.AddLimitRow();
|
| | | //添加重置电机行
|
| | | this.AddElectricalMachineryRow();
|
| | | //导轨长度为0时
|
| | | if (curtainData.CurtainLength <= 0)
|
| | | {
|
| | | //电机数据异常,请重置电机
|
| | | this.ShowMassage(ShowMsgType.Error, Language.StringByID(R.MyInternationalizationString.uCurtainDataIsErrorPleaseResetCurtain));
|
| | | try
|
| | | {
|
| | | //设备异常补救 -> 添加重置电机行
|
| | | this.AddElectricalMachineryRow();
|
| | | return;
|
| | | }
|
| | | catch (Exception ex2) |
| | | {
|
| | | HdlLogLogic.Current.WriteLog(ex2, "开合帘补救异常1");
|
| | | return;
|
| | | }
|
| | | }
|
| | |
|
| | | //限位数据接收
|
| | | this.ReceiveLimitData();
|
| | | try
|
| | | {
|
| | | //添加方向行
|
| | | this.AddDirectionRow();
|
| | | //添加限位行
|
| | | this.AddLimitRow();
|
| | | //添加重置电机行
|
| | | this.AddElectricalMachineryRow();
|
| | |
|
| | | //限位数据接收
|
| | | this.ReceiveLimitData();
|
| | | }
|
| | | catch (Exception ex)
|
| | | {
|
| | | //Log出力
|
| | | string msg = "当前激活的界面[" + UserCenterResourse.NowActionFormID + "]";
|
| | | HdlLogLogic.Current.WriteLog(ex, msg);
|
| | | //电机数据异常,请重置电机
|
| | | this.ShowMassage(ShowMsgType.Error, Language.StringByID(R.MyInternationalizationString.uCurtainDataIsErrorPleaseResetCurtain));
|
| | | try
|
| | | {
|
| | | this.listView.RemoveAll();
|
| | | //设备异常补救 -> 添加重置电机行
|
| | | this.AddElectricalMachineryRow();
|
| | | }
|
| | | catch (Exception ex2) { HdlLogLogic.Current.WriteLog(ex2, "开合帘补救异常2"); }
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | |
| | |
|
| | | var form = new BottomItemSelectForm();
|
| | | form.AddForm(Language.StringByID(R.MyInternationalizationString.uDirectionSelect), listText, nowSelectNo);
|
| | | form.FinishSelectEvent += async (index) =>
|
| | | form.FinishSelectEvent += (index) =>
|
| | | {
|
| | | //变更方向
|
| | | var result = await HdlDeviceCurtainLogic.Current.SetCurtainDirection(curtainDevice, index == 0 ? false : true);
|
| | | var result = HdlDeviceCurtainLogic.Current.SetCurtainDirection(curtainDevice, index == 0 ? false : true);
|
| | | if (result == false)
|
| | | {
|
| | | return;
|
| | |
| | | var btnRinght = rowLimit.AddMostRightEmptyIcon(58, 58);
|
| | | rowLimit.ChangedChidrenBindMode(btnRinght, ChidrenBindMode.NotBind);
|
| | | btnRinght.UseClickStatu = false;
|
| | | btnRinght.UnSelectedImagePath = "Item/Next.png";
|
| | | btnRinght.UnSelectedImagePath = "Item/RightNext.png";
|
| | | btnRinght.SelectedImagePath = "Item/Down.png";
|
| | | btnRinght.IsSelected = true;
|
| | | btnRinght.ButtonClickEvent += (sender, e) =>
|
| | |
| | | frameBack.AddChidren(btnProgressView);
|
| | |
|
| | | int progressValue = (int)(curtainData.OpenLimitValue / (curtainData.CurtainLength * 1.0) * 100);
|
| | | //设置百分比的初始值
|
| | | curtainData.OpenLimitPersent = progressValue;
|
| | | var btnProgress1 = new NormalViewControl(200, 50, true);
|
| | | btnProgress1.X = Application.GetRealWidth(200);
|
| | | btnProgress1.Y = btnProgressView.Y;
|
| | |
| | | btnProgress1.Text = progressValue + "%";
|
| | | frameBack.AddChidren(btnProgress1);
|
| | | //进度条
|
| | | this.openSeekBar = new SeekBarControl(965);
|
| | | this.openSeekBar = new SeekBarControl(965);
|
| | | openSeekBar.Y = btnProgressView.Bottom + Application.GetRealHeight(46);
|
| | | openSeekBar.ProgressBarColor = 0xff288bfd;
|
| | | openSeekBar.Progress = progressValue;
|
| | |
| | | {
|
| | | return;
|
| | | }
|
| | | openSeekBar.Progress -= 1;
|
| | | openSeekBar.Progress -= 5;
|
| | | openSeekBar.ProgressChangedEvent(1, openSeekBar.Progress);
|
| | | };
|
| | |
|
| | |
| | | {
|
| | | return;
|
| | | }
|
| | | openSeekBar.Progress += 1;
|
| | | openSeekBar.Progress += 5;
|
| | | openSeekBar.ProgressChangedEvent(1, openSeekBar.Progress);
|
| | | };
|
| | |
|
| | |
| | | frameBack.AddChidren(btnSave);
|
| | | btnSave.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | if (this.receiveOpenlimit == true)
|
| | | //2020.05.17:追加虚拟住宅可以直接点击
|
| | | if (this.receiveOpenlimit == true || Common.Config.Instance.Home.IsVirtually == true)
|
| | | {
|
| | | //确认开限位点
|
| | | this.SaveOpenLimit();
|
| | |
| | | //数据变更,百分比
|
| | | curtainData.OpenLimitPersent = value;
|
| | | };
|
| | | //虚拟住宅不需要监听
|
| | | if (Common.Config.Instance.Home.IsVirtually == true)
|
| | | {
|
| | | return;
|
| | | }
|
| | |
|
| | | HdlThreadLogic.Current.RunThread(async () =>
|
| | | {
|
| | | //处理中
|
| | | bool checking = false;
|
| | | while (openSeekBar.Parent != null)
|
| | | {
|
| | | int nowValue = curtainData.OpenLimitPersent;
|
| | | if (oldProValue == nowValue || checking == true)
|
| | | if (oldProValue == nowValue)
|
| | | {
|
| | | //值不等才处理
|
| | | await Task.Delay(500);
|
| | | continue;
|
| | | }
|
| | | oldProValue = nowValue;
|
| | | checking = true;
|
| | | if (curtainData.DeleteOpenLimit == true)
|
| | | {
|
| | | //重置开限位点
|
| | | var result = await HdlDeviceCurtainLogic.Current.DeleteCurtainLimitPoint(curtainDevice, Rollershade.LimiType.UpLimit);
|
| | | if (result == false)
|
| | | {
|
| | | checking = false;
|
| | | continue;
|
| | | }
|
| | | curtainData.DeleteOpenLimit = false;
|
| | | }
|
| | |
|
| | | //将窗帘调整到指定百分比
|
| | | this.sendDiv = 1;
|
| | | curtainDevice.WcdGoToTiltValue(nowValue);
|
| | | checking = false;
|
| | | }
|
| | | });
|
| | | }
|
| | |
| | | {
|
| | | //确认当前位置为开限位?
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.uCommitCurtainOpenLimitMsg);
|
| | | this.ShowMassage(ShowMsgType.Confirm, msg, async () =>
|
| | | this.ShowMassage(ShowMsgType.Confirm, msg, () =>
|
| | | {
|
| | | decimal openValue = ((decimal)curtainData.OpenLimitPersent / 100) * curtainData.CurtainLength;
|
| | | decimal closeValue = ((decimal)curtainData.CloseLimitPersent / 100) * curtainData.CurtainLength;
|
| | | if (openValue < 0) { openValue = 0; }
|
| | | if (closeValue < 0) { closeValue = curtainData.CurtainLength; }
|
| | | //执行确认及覆盖上限位点
|
| | | var result = await HdlDeviceCurtainLogic.Current.CommitCurtainLimitPoint(curtainDevice, Rollershade.CurtainPrivateInstalledLimi.UpLimit,
|
| | | curtainData.OpenLimitPersent, curtainData.CloseLimitPersent);
|
| | | var result = HdlDeviceCurtainLogic.Current.SetAutoOpenCurtainLimitPoint(curtainDevice, (int)openValue, (int)closeValue, curtainData.CurtainLength);
|
| | | if (result == true)
|
| | | {
|
| | | curtainData.DeleteOpenLimit = true;
|
| | | this.receiveOpenlimit = false;
|
| | | }
|
| | | });
|
| | |
| | | frameBack.AddChidren(btnProgressView);
|
| | |
|
| | | int progressValue = (int)(curtainData.CloseLimitValue / (curtainData.CurtainLength * 1.0) * 100);
|
| | | //设置百分比的初始值
|
| | | curtainData.CloseLimitPersent = progressValue;
|
| | | var btnProgress1 = new NormalViewControl(200, 50, true);
|
| | | btnProgress1.X = Application.GetRealWidth(200);
|
| | | btnProgress1.Y = btnProgressView.Y;
|
| | |
| | | btnProgress1.Text = progressValue + "%";
|
| | | frameBack.AddChidren(btnProgress1);
|
| | | //进度条
|
| | | this.closeSeekBar = new SeekBarControl(965);
|
| | | this.closeSeekBar = new SeekBarControl(965);
|
| | | closeSeekBar.Y = btnProgressView.Bottom + Application.GetRealHeight(46);
|
| | | closeSeekBar.ProgressBarColor = 0xff288bfd;
|
| | | closeSeekBar.Progress = progressValue;
|
| | |
| | | {
|
| | | return;
|
| | | }
|
| | | closeSeekBar.Progress -= 1;
|
| | | closeSeekBar.Progress -= 5;
|
| | | closeSeekBar.ProgressChangedEvent(1, closeSeekBar.Progress);
|
| | | };
|
| | |
|
| | |
| | | frameBack.AddChidren(btnPlus);
|
| | | btnPlus.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | if (closeSeekBar.Progress >=100)
|
| | | if (closeSeekBar.Progress >= 100)
|
| | | {
|
| | | return;
|
| | | }
|
| | | closeSeekBar.Progress += 1;
|
| | | closeSeekBar.Progress += 5;
|
| | | closeSeekBar.ProgressChangedEvent(1, closeSeekBar.Progress);
|
| | | };
|
| | |
|
| | |
| | | frameBack.AddChidren(btnSave);
|
| | | btnSave.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | if (this.receiveCloseLimit == true)
|
| | | //2020.05.17:追加虚拟住宅可以直接点击
|
| | | if (this.receiveCloseLimit == true || Common.Config.Instance.Home.IsVirtually == true)
|
| | | {
|
| | | //保存合限位点
|
| | | this.SaveCloseLimit();
|
| | |
| | | //数据变更,百分比
|
| | | curtainData.CloseLimitPersent = value;
|
| | | };
|
| | | //虚拟住宅不需要监听
|
| | | if (Common.Config.Instance.Home.IsVirtually == true)
|
| | | {
|
| | | return;
|
| | | }
|
| | |
|
| | | HdlThreadLogic.Current.RunThread(async () =>
|
| | | {
|
| | | //处理中
|
| | | bool checking = false;
|
| | | while (closeSeekBar.Parent != null)
|
| | | {
|
| | | int nowValue = curtainData.CloseLimitPersent;
|
| | | if (oldProValue == nowValue || checking == true)
|
| | | if (oldProValue == nowValue)
|
| | | {
|
| | | //值不等才处理
|
| | | await Task.Delay(500);
|
| | | continue;
|
| | | }
|
| | | checking = true;
|
| | | oldProValue = nowValue;
|
| | | if (curtainData.DeleteCloseLimit == true)
|
| | | {
|
| | | //重置合限位点
|
| | | var result = await HdlDeviceCurtainLogic.Current.DeleteCurtainLimitPoint(curtainDevice, Rollershade.LimiType.DownLimit);
|
| | | if (result == false)
|
| | | {
|
| | | continue;
|
| | | }
|
| | | curtainData.DeleteCloseLimit = false;
|
| | | }
|
| | |
|
| | | //将窗帘调整到指定百分比
|
| | | this.sendDiv = 2;
|
| | | curtainDevice.WcdGoToTiltValue(nowValue);
|
| | | checking = false;
|
| | | }
|
| | | });
|
| | | }
|
| | |
| | | {
|
| | | //确认当前位置为合限位?
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.uCommitCurtainCloseLimitMsg);
|
| | | this.ShowMassage(ShowMsgType.Confirm, msg, async () =>
|
| | | this.ShowMassage(ShowMsgType.Confirm, msg, () =>
|
| | | {
|
| | | //执行确认及覆盖合限位点
|
| | | var result = await HdlDeviceCurtainLogic.Current.CommitCurtainLimitPoint(curtainDevice, Rollershade.CurtainPrivateInstalledLimi.DownLimit,
|
| | | curtainData.OpenLimitPersent, curtainData.CloseLimitPersent);
|
| | | decimal openValue = ((decimal)curtainData.OpenLimitPersent / 100) * curtainData.CurtainLength;
|
| | | decimal closeValue = ((decimal)curtainData.CloseLimitPersent / 100) * curtainData.CurtainLength;
|
| | | if (openValue < 0) { openValue = 0; }
|
| | | if (closeValue < 0) { closeValue = curtainData.CurtainLength; }
|
| | | //执行确认及覆盖上限位点
|
| | | var result = HdlDeviceCurtainLogic.Current.SetAutoOpenCurtainLimitPoint(curtainDevice, (int)openValue, (int)closeValue, curtainData.CurtainLength);
|
| | |
|
| | | if (result == true)
|
| | | {
|
| | | curtainData.DeleteCloseLimit = true;
|
| | | this.receiveCloseLimit = false;
|
| | | }
|
| | | });
|
| | |
| | | rowReset.AddBottomLine();
|
| | | rowReset.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //如果当前是虚拟住宅
|
| | | if (Common.Config.Instance.Home.IsVirtually == true)
|
| | | {
|
| | | return;
|
| | | }
|
| | | //重置电机将初始化{0}方向与限位设置,确认继续?
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.uResetElectricalMachineryMsg);
|
| | | msg = msg.Replace("{0}", "\r\n");
|
| | |
| | |
|
| | | //每10的长度大概是2秒,多预留1次出来
|
| | | int waitCount = ((curtainData.CurtainLength / 10) + 1) * 3;
|
| | | if (waitCount < 12)
|
| | | {
|
| | | waitCount = 12;
|
| | | }
|
| | |
|
| | | int timeCount = 0;
|
| | | while (timeCount <= waitCount)
|
| | |
| | | /// <returns></returns>
|
| | | private bool InitCurtainDefultData()
|
| | | {
|
| | | //开启进度条
|
| | | this.ShowProgressBar();
|
| | |
|
| | | this.curtainData = new CurtainData();
|
| | | this.receiveOpenlimit = false;
|
| | | this.receiveCloseLimit = false;
|
| | | this.sendDiv = 0;
|
| | |
|
| | | bool receiptData = false;
|
| | | //如果当前是虚拟住宅
|
| | | if (Common.Config.Instance.Home.IsVirtually == true)
|
| | | {
|
| | | var data = ModelData.DeviceModelDataLogic.Current.GetCurtainLimitPoint(curtainDevice);
|
| | | curtainData.Direction = data.Direction;
|
| | | curtainData.CurtainLength = data.curtainLength;
|
| | | curtainData.OpenLimitValue = data.upLimit;
|
| | | curtainData.CloseLimitValue = data.downLimit;
|
| | | return true;
|
| | | }
|
| | |
|
| | | //开启进度条
|
| | | this.ShowProgressBar();
|
| | |
|
| | | int receiptDataCount = 0;
|
| | | string mainkeys = LocalDevice.Current.GetDeviceMainKeys(curtainDevice);
|
| | | HdlGatewayReceiveLogic.Current.AddAttributeEvent("CurtainDeviceAttribute", ReceiveComandDiv.A设备属性上报, (device) =>
|
| | | {
|
| | |
| | | //正向
|
| | | curtainData.Direction = false;
|
| | | }
|
| | | receiptDataCount++;
|
| | | }
|
| | | else if (attriBute.AttributeId == 1)
|
| | | {
|
| | | //窗帘总长
|
| | | curtainData.CurtainLength = attriBute.AttriButeData;
|
| | | receiptDataCount++;
|
| | | }
|
| | | else if (attriBute.AttributeId == 16)
|
| | | {
|
| | | //开限位
|
| | | curtainData.OpenLimitValue = attriBute.AttriButeData;
|
| | | receiptDataCount++;
|
| | | }
|
| | | else if (attriBute.AttributeId == 17)
|
| | | {
|
| | | //合限位
|
| | | curtainData.CloseLimitValue = attriBute.AttriButeData;
|
| | | //数据接收结束
|
| | | receiptData = true;
|
| | | receiptDataCount++;
|
| | | }
|
| | | }
|
| | | });
|
| | |
| | | HdlDeviceCurtainLogic.Current.SetGetCurtainLimitSettionComand(curtainDevice);
|
| | |
|
| | | int timeCount = 30;
|
| | | while (receiptData == false && timeCount >= 0)
|
| | | while (receiptDataCount != 4 && timeCount >= 0)
|
| | | {
|
| | | System.Threading.Thread.Sleep(100);
|
| | | timeCount--;
|
| | |
| | | }
|
| | | //移除监听
|
| | | HdlGatewayReceiveLogic.Current.RemoveEvent("CurtainDeviceAttribute");
|
| | |
|
| | | //备份窗帘数据
|
| | | if (this.backupCurtainData == true)
|
| | | {
|
| | | this.backupCurtainData = false;
|
| | | HdlThreadLogic.Current.RunThread(async () =>
|
| | | {
|
| | | //方向备份
|
| | | await HdlDeviceCurtainLogic.Current.BackupCurtainDirection(curtainDevice, curtainData.Direction);
|
| | | //限位备份
|
| | | int uplimit= (int)(curtainData.OpenLimitValue / (curtainData.CurtainLength * 1.0) * 100);
|
| | | int downlimit = (int)(curtainData.CloseLimitValue / (curtainData.CurtainLength * 1.0) * 100);
|
| | | await HdlDeviceCurtainLogic.Current.BackupCurtainLimitPoint(curtainDevice, uplimit, downlimit);
|
| | | });
|
| | | }
|
| | |
|
| | | return true;
|
| | | }
|
| | |
| | | HdlGatewayReceiveLogic.Current.RemoveEvent("CurtainDeviceAttribute");
|
| | | HdlGatewayReceiveLogic.Current.RemoveEvent("ReceiveLimitData");
|
| | |
|
| | | UserView.HomePage.Instance.ScrollEnabled = true;
|
| | |
|
| | | base.CloseFormBefore();
|
| | | }
|
| | |
|
| | |
| | | /// false:电机方向正向;true:电机方向反向
|
| | | /// </summary>
|
| | | public bool Direction = false;
|
| | | /// <summary>
|
| | | /// 是否重置开限位点
|
| | | /// </summary>
|
| | | public bool DeleteOpenLimit = true;
|
| | | /// <summary>
|
| | | /// 是否重置合限位点
|
| | | /// </summary>
|
| | | public bool DeleteCloseLimit = true;
|
| | | /// <summary>
|
| | | /// 开限位的值
|
| | | /// </summary>
|