wxr
2022-11-10 bf3d64379bdf4424394103b31531a25d30be85d8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
using Shared;
using HDL_ON.Stan;
using HDL_ON.UI.CSS;
using HDL_ON.Entity;
using System;
using HDL_ON.DAL.Server;
 
namespace HDL_ON.UI
{
    public class SenesorMegahealthPage : DeviceFunctionCardCommonForm
    {
        #region ■ 变量声明___________________________
 
        /// <summary>
        /// 图标
        /// </summary>
        private IconViewControl btnIcon = null;
        /// <summary>
        /// 文本控件
        /// </summary>
        private NormalViewControl btnSuctionView = null;
        /// <summary>
        /// 退出实验室模式控制区域
        /// </summary>
        FrameLayout exitLabView;
 
 
        #endregion
 
        #region ■ 初始化_____________________________
 
        /// <summary>
        /// 初始化白色区域的内容
        /// </summary>
        public override void InitFrameWhiteContent()
        {
            base.SetTitleText(Language.StringByID(StringId.SenesorMillimeterWave));
 
            //添加第二索引页
            this.AddSecondPage();
            //初始化第一个索引页的内容
            this.InitFrameWhiteContent1();
            //初始化第二个索引页的内容
            this.InitFrameWhiteContent2();
 
            //刷新当前设备的状态缓存
            this.RefreshNowDeviceStatuMemory(this.device);
            //刷新界面状态
            this.RefreshFormStatu();
            //读取状态
            new System.Threading.Thread(() =>
            {
                if (device.spk == SPK.SenesorMegahealth || device.spk == SPK.SensorMmvPose || device.spk == SPK.SenesorMegahealth2)
                {
                    DriverLayer.Control.Ins.SendReadCommand(device, true);
                }
            })
            { IsBackground = true }.Start();
        }
 
        /// <summary>
        /// 初始化第一个索引页的内容
        /// </summary>
        private void InitFrameWhiteContent1()
        {
            btnIcon = new IconViewControl(198)
            {
                Gravity = Gravity.CenterHorizontal,
                Y = Application.GetRealWidth(146),
                UnSelectedImagePath = "FunctionIcon/ArmSensor/UnderProtectionBgIcon.png",
            };
            FrameWhiteCentet1.AddChidren(btnIcon);
 
            btnSuctionView = new NormalViewControl(300, 84, true)
            {
                Gravity = Gravity.CenterHorizontal,
                Y = btnIcon.Bottom,
                TextAlignment = TextAlignment.Center,
                TextSize = CSS_FontSize.TextFontSize,
                TextColor = CSS_Color.TextualColor,
                SelectedTextColor = CSS_Color.MainColor,
            };
            FrameWhiteCentet1.AddChidren(btnSuctionView);
 
 
            //int i = 0;
            //btnIcon.MouseUpEventHandler = (sender, e) => {
            //    device.GetAttribute(FunctionAttributeKey.TargetStatus).state = i.ToString();
            //    i++;
            //    RefreshFormStatu();
            //};
 
 
            
            var btnInstantaneousValue = new Button()
            {
                Gravity = Gravity.CenterHorizontal,
                Y = Application.GetRealHeight(391),
                Width = Application.GetMinRealAverage(32),
                Height = Application.GetMinRealAverage(32),
                UnSelectedImagePath = "FunctionIcon/EnvironmentalScience/DiagramIconOn.png",
            };
            FrameWhiteCentet1.AddChidren(btnInstantaneousValue);
            var btnInstantaneousValueText = new Button()
            {
                Gravity = Gravity.CenterHorizontal,
                Y = btnInstantaneousValue.Bottom,
                Width = Application.GetRealWidth(96),
                Height = Application.GetRealHeight(29),
                TextAlignment = TextAlignment.Center,
                TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
                TextColor = CSS_Color.TextualColor,
                TextID = StringId.AlarmDataStatistics,
                IsMoreLines = true
            };
            FrameWhiteCentet1.AddChidren(btnInstantaneousValueText);
            EventHandler<MouseEventArgs> eventHandler = (sender, e) => {
                var page = new SensorMegahealth_AlarmDataStatisticsPage(device);
                MainPage.BasePageView.AddChidren(page);
                page.LoadPage();
                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
            };
            btnInstantaneousValue.MouseUpEventHandler = eventHandler;
            btnInstantaneousValueText.MouseUpEventHandler = eventHandler;
 
 
            exitLabView = new FrameLayout()
            {
                Y = Application.GetRealHeight(391),
                Height = Application.GetRealHeight(135),
                BackgroundColor = CSS_Color.MainBackgroundColor,
                Visible = device.extSet.labModel,
            };
            FrameWhiteCentet1.AddChidren(exitLabView);
 
            var labTipText = new Button()
            {
                Y = Application.GetRealHeight(10),
                Gravity = Gravity.CenterHorizontal,
                Width = Application.GetRealWidth(250),
                Height = Application.GetRealHeight(50),
                TextColor = CSS_Color.TextualColor,
                TextID = StringId.LabTipText,
                IsMoreLines = true,
                TextAlignment = TextAlignment.CenterLeft,
                TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
            };
            exitLabView.AddChidren(labTipText);
 
            var btnExitLab = new Button()
            {
                Y = Application.GetRealHeight(75),
                Gravity = Gravity.CenterHorizontal,
                Width = Application.GetRealWidth(148),
                Height = Application.GetRealHeight(40),
                TextAlignment = TextAlignment.Center,
                TextColor = CSS_Color.MainBackgroundColor,
                IsBold = true,
                Radius = (uint)Application.GetRealHeight(20),
                TextSize = 16,
                TextID = StringId.ExitLabModel,
                BackgroundColor = CSS_Color.MainColor,
            };
            exitLabView.AddChidren(btnExitLab);
            btnExitLab.MouseUpEventHandler = (sender, e) => {
 
                new System.Threading.Thread(() =>
                {
                    device.extSet.labModel = false;
                    var result = new HttpServerRequest().DeviceExtSet(device.deviceId, device.extSet);
                    Application.RunOnMainThread(() =>
                    {
                        if (result != null && result.Code == StateCode.SUCCESS)
                        {
                            exitLabView.Visible = false;
                        }
                    });
                })
                { IsBackground = true }.Start();
            };
            //回到置顶刷新
            base.SettionFinishEvent += () => {
                exitLabView.Visible = device.extSet.labModel;
            };
 
 
 
        }
     
 
 
        /// <summary>
        /// 初始化第二个索引页的内容
        /// </summary>
        private void InitFrameWhiteContent2()
        {
            var paging = new ArmSensorHistroyPaging(device);
            paging.InitFrame(FrameWhiteCentet2);
        }
 
        #endregion
 
        #region ■ 设备状态反馈_______________________
 
        /// <summary>
        /// 设备状态反馈
        /// </summary>
        /// <param name="i_LocalDevice"></param>
        public override void DeviceStatuPush(Function i_LocalDevice)
        {
            //不是同一个东西
            if (this.device.sid != i_LocalDevice.sid) { return; }
 
            //刷新当前设备的状态缓存
            this.RefreshNowDeviceStatuMemory(i_LocalDevice);
            //刷新界面状态
            this.RefreshFormStatu();
        }
 
        #endregion
 
        #region ■ 发送各种命令_______________________
 
        #endregion
 
        #region ■ 刷新界面状态_______________________
 
        /// <summary>
        /// 刷新界面状态
        /// </summary>
        private void RefreshFormStatu()
        {
            Application.RunOnMainThread(() => {
                var temp = device.attributes.Find((sta) => sta.key == FunctionAttributeKey.ActionStatus);
                
                if (temp != null)
                {
                    if (temp.state == "fall")   //跌倒
                    {
                        btnIcon.UnSelectedImagePath = "FunctionIcon/ArmSensor/SomeoneFellBgIcon.png";
                        btnSuctionView.TextID = StringId.SomeoneFell;
                        btnSuctionView.IsSelected = true;
                    }
                    else if (temp.state == "uninhabited")//无人
                    {
                        btnIcon.UnSelectedImagePath = "FunctionIcon/ArmSensor/UnderProtectionBgIcon.png";
                        btnSuctionView.TextID = StringId.SensorNormalState;
                        btnSuctionView.IsSelected = false;
                    }
                    else//有人
                    {
                        btnIcon.UnSelectedImagePath = "FunctionIcon/ArmSensor/SomeoneInBgIcon.png";
                        btnSuctionView.TextID = StringId.SomeoneIn;
                        btnSuctionView.IsSelected = true;
                    }
                }
 
                else
                {
                    temp = device.attributes.Find((sta) => sta.key == FunctionAttributeKey.PeopleStatus);
                    if (temp != null)
                    {
                        if (temp.state == "true")
                        {
                            btnIcon.UnSelectedImagePath = "FunctionIcon/ArmSensor/SomeoneInBgIcon.png";
                            btnIcon.IsSelected = true;
                            btnIcon.IsSelected = false;
                            btnSuctionView.TextID = StringId.SomeoneIn;
                            btnSuctionView.IsSelected = true;
                        }
                        else
                        {
                            btnIcon.IsSelected = false;
                            btnSuctionView.TextID = StringId.SensorNormalState;
                            btnSuctionView.IsSelected = false;
                        }
                        //增加实验室模式反馈
                        var tempStatus = device.attributes.Find((sta) => sta.key == FunctionAttributeKey.TargetStatus);
                        if(tempStatus != null)
                        {
 
                            switch (tempStatus.state)
                            {//0空,1走,2跑,3坐,4跌倒,5站
                                case "0":
                                    btnIcon.UnSelectedImagePath = "FunctionIcon/ArmSensor/UnderProtectionBgIcon.png";
                                    btnIcon.IsSelected = true;
                                    btnIcon.IsSelected = false;
                                    btnSuctionView.TextID = StringId.SensorNormalState;
                                    btnSuctionView.IsSelected = false;
                                    break;
                                case "1":
                                    btnIcon.UnSelectedImagePath = "FunctionIcon/ArmSensor/SomeoneInBgIcon.png";
                                    btnIcon.IsSelected = true;
                                    btnIcon.IsSelected = false;
                                    btnSuctionView.TextID = StringId.Someone;
                                    btnSuctionView.IsSelected = true;
                                    break;
                                case "2":
                                    if (device.extSet.labModel)
                                    {
                                        btnIcon.UnSelectedImagePath = "FunctionIcon/ArmSensor/SomeoneRunBgIcon.png";
                                        btnIcon.IsSelected = true;
                                        btnIcon.IsSelected = false;
                                        btnSuctionView.TextID = StringId.SomeoneRunning;
                                        btnSuctionView.IsSelected = true;
                                    }
                                    else
                                    {
                                        btnIcon.UnSelectedImagePath = "FunctionIcon/ArmSensor/SomeoneInBgIcon.png";
                                        btnIcon.IsSelected = true;
                                        btnIcon.IsSelected = false;
                                        btnSuctionView.TextID = StringId.Someone;
                                        btnSuctionView.IsSelected = true;
                                    }
                                    break;
                                case "3":
                                    if (device.extSet.labModel)
                                    {
                                        btnIcon.UnSelectedImagePath = "FunctionIcon/ArmSensor/SomeoneSitBgIcon.png";
                                        btnIcon.IsSelected = true;
                                        btnIcon.IsSelected = false;
                                        btnSuctionView.TextID = StringId.SomeoneSitting;
                                        btnSuctionView.IsSelected = true;
                                    }
                                    else
                                    {
                                        btnIcon.UnSelectedImagePath = "FunctionIcon/ArmSensor/SomeoneInBgIcon.png";
                                        btnIcon.IsSelected = true;
                                        btnIcon.IsSelected = false;
                                        btnSuctionView.TextID = StringId.Someone;
                                        btnSuctionView.IsSelected = true;
                                    }
                                    break;
                                case "4":
                                    btnIcon.UnSelectedImagePath = "FunctionIcon/ArmSensor/SomeoneFellBgIcon.png";
                                    btnIcon.IsSelected = true;
                                    btnIcon.IsSelected = false;
                                    btnSuctionView.TextID = StringId.SomeoneFell;
                                    btnSuctionView.IsSelected = true;
                                    break;
                                case "5":
                                    if (device.extSet.labModel)
                                    {
                                        btnIcon.UnSelectedImagePath = "FunctionIcon/ArmSensor/SomeoneStandBgIcon.png";
                                        btnIcon.IsSelected = true;
                                        btnIcon.IsSelected = false;
                                        btnSuctionView.TextID = StringId.SomeoneStanding;
                                        btnSuctionView.IsSelected = true;
                                    }
                                    else
                                    {
                                        btnIcon.UnSelectedImagePath = "FunctionIcon/ArmSensor/SomeoneInBgIcon.png";
                                        btnIcon.IsSelected = true;
                                        btnIcon.IsSelected = false;
                                        btnSuctionView.TextID = StringId.Someone;
                                        btnSuctionView.IsSelected = true;
                                    }
                                    break;
                                default:
 
                                    break;
                            }
 
 
                        }
                    }
                }
 
            });
        }
 
        #endregion
 
        #region ■ 一般方法___________________________
 
        /// <summary>
        /// 刷新当前设备的状态缓存
        /// </summary>
        private void RefreshNowDeviceStatuMemory(Function i_LocalDevice)
        {
            //foreach (var data in i_LocalDevice.status)
            //{
            //    if (data.key == FunctionAttributeKey.Status)
            //    {
            //        Application.RunOnMainThread(() =>
            //        {
            //            if (data.value.ToLower() == "open")
            //            {
            //                this.btnIcon.IsSelected = true;
            //                this.btnSuctionView.IsSelected = true;
            //                this.btnSuctionView.TextID = StringId.Open;
            //            }
            //            else
            //            {
            //                this.btnIcon.IsSelected = false;
            //                this.btnSuctionView.IsSelected = false;
            //                this.btnSuctionView.TextID = StringId.Close;
            //            }
            //        });
            //    }
            //}
        }
 
        #endregion
    }
 
}