Example #1
0
        //*********************************************************************************************************温湿度↑
        //*********************************************************************************************************光照↓
        public void 设置光照报警范围()
        {
            ViewModel vm      = ViewModel.getInstance();
            NodeInfo  TheNode = XML_获取设备节点信息("无线光照度采集");

            CM_IOT_IDC_SetLimit(CM_HANDLE, int.Parse(ViewModel.getInstance().model.nvsid), TheNode.netid, TheNode.nodeaddr, float.Parse(vm.gauge.光照度_下限), float.Parse(vm.gauge.光照度_上限));
        }
Example #2
0
        public void 温度单次取样()
        {
            ViewModel vm      = ViewModel.getInstance();
            NodeInfo  TheNode = XML_获取设备节点信息("无线温度采集");

            CM_IOT_TDC_Sampling(CM_HANDLE, int.Parse(vm.model.nvsid), TheNode.netid, TheNode.nodeaddr);
        }
Example #3
0
        public void 开启温度连续取样()
        {
            ViewModel vm      = ViewModel.getInstance();
            NodeInfo  TheNode = XML_获取设备节点信息("无线温度采集");

            CM_IOT_TDC_StartContinuousSampling(CM_HANDLE, int.Parse(vm.model.nvsid), TheNode.netid, TheNode.nodeaddr, 1000, 1);
        }
Example #4
0
        public void 查询温度报警范围()
        {
            ViewModel vm      = ViewModel.getInstance();
            NodeInfo  TheNode = XML_获取设备节点信息("无线温度采集");

            CM_IOT_TDC_QueryLimit(CM_HANDLE, int.Parse(vm.model.nvsid), TheNode.netid, TheNode.nodeaddr);
        }
Example #5
0
        private void login(object sender, RoutedEventArgs e)
        {
            Button a = (Button)sender;

            a.IsEnabled = false;
            ViewModel vm  = ViewModel.getInstance();
            IOT       iot = IOT.getInstance();
            Thread    t   = new Thread(消息接收);


            iot.模块初始化();
            int result = iot.登录();

            if (result == 0)
            {
                MessageBox.Show("登陆失败"); return;
            }
            result = iot.设置UDP通知();
            if (result == 0)
            {
                MessageBox.Show("设置UDP通知失败"); return;
            }
            iot.XML_设置目录();
            result = iot.XML_请求更新文件();

            if (result == 0)
            {
                MessageBox.Show("请求更新文件失败"); return;
            }
            Thread.Sleep(500);

            t.Start();
            this.Close();
        }
Example #6
0
        public MainWindow()
        {
            this.DataContext = ViewModel.getInstance();
            登录 a = new 登录();

            a.Show();

            InitializeComponent();


            DoubleAnimation 动画 = new DoubleAnimation();

            动画.To       = 100;
            动画.Duration = TimeSpan.FromMilliseconds(43.0 * (100 - progress.Value));
            Storyboard.SetTargetName(动画, progress.Name);
            Storyboard.SetTargetProperty(动画, new PropertyPath(ProgressBar.ValueProperty));
            窗帘开.Children.Add(动画);
            动画          = new DoubleAnimation();
            动画.To       = 0;
            动画.Duration = TimeSpan.FromMilliseconds(43.0 * progress.Value);
            Storyboard.SetTargetName(动画, progress.Name);
            Storyboard.SetTargetProperty(动画, new PropertyPath(ProgressBar.ValueProperty));
            窗帘关.Children.Add(动画);

            c1        = chart1;
            c2        = chart2;
            c3        = chart3;
            c1.View3D = true;
            c2.View3D = true;
            c3.View3D = true;
            c1.Series.Add(line1);
            c2.Series.Add(line2_1);
            c2.Series.Add(line2_2);
            c3.Series.Add(line3);
        }
Example #7
0
        public void 关灯(int index)
        {
            if (index != 1 && index != 2 && index != 3)
            {
                MessageBox.Show("获取灯节点信息失败" + index.ToString());
            }
            string temp = "灯";

            temp += index.ToString();
            NodeInfo TheNode = XML_获取设备节点信息(temp);

            CM_IOT_LAMP_Ctrl(CM_HANDLE, int.Parse(ViewModel.getInstance().model.nvsid), TheNode.netid, TheNode.nodeaddr, 0);
        }
Example #8
0
        public int XML_请求更新文件()
        {
            int result = CM_QueryNodesStatusOfNVS(CM_HANDLE, int.Parse(ViewModel.getInstance().model.nvsid));

            return(result);
        }
Example #9
0
        public void 警笛(int seconds)
        {
            NodeInfo TheNode = XML_获取设备节点信息("警笛");

            CM_IOT_WCAW_Ctrl(CM_HANDLE, int.Parse(ViewModel.getInstance().model.nvsid), TheNode.netid, TheNode.nodeaddr, seconds);
        }
Example #10
0
        public void 电源关闭()
        {
            NodeInfo TheNode = XML_获取设备节点信息("电源控制");

            CM_IOT_POWER_Ctrl(CM_HANDLE, int.Parse(ViewModel.getInstance().model.nvsid), TheNode.netid, TheNode.nodeaddr, 0);
        }
Example #11
0
        public void 实验箱关闭()
        {
            NodeInfo TheNode = XML_获取设备节点信息("实验箱取电");

            CM_IOT_CONTROLTC_Ctrl(CM_HANDLE, int.Parse(ViewModel.getInstance().model.nvsid), TheNode.netid, TheNode.nodeaddr, 0);
        }
Example #12
0
        public void 暂停窗帘()
        {
            NodeInfo TheNode = XML_获取设备节点信息("窗帘");

            CM_IOT_EC_Ctrl(CM_HANDLE, int.Parse(ViewModel.getInstance().model.nvsid), TheNode.netid, TheNode.nodeaddr, 0);
        }
Example #13
0
        public int 登录()
        {
            ViewModel vm = ViewModel.getInstance();

            return(CM_Login(CM_HANDLE, vm.model.IP, vm.model.用户名, vm.model.密码));
        }
Example #14
0
 public 关于()
 {
     InitializeComponent();
     this.DataContext = ViewModel.getInstance();
 }
Example #15
0
        public void 查询光照报警范围()
        {
            NodeInfo TheNode = XML_获取设备节点信息("无线光照度采集");

            CM_IOT_IDC_QueryLimit(CM_HANDLE, int.Parse(ViewModel.getInstance().model.nvsid), TheNode.netid, TheNode.nodeaddr);
        }
Example #16
0
        public void 关闭温湿度连续取样()
        {
            NodeInfo TheNode = XML_获取设备节点信息("无线温湿度采集");

            CM_IOT_THDC_StopContinuousSampling(CM_HANDLE, int.Parse(ViewModel.getInstance().model.nvsid), TheNode.netid, TheNode.nodeaddr);
        }
Example #17
0
        public void 消息接收()
        {
            int recv;

            byte[]     data = new byte[1024];
            string     msg;
            IPEndPoint ip      = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 10000);
            Socket     newsock = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);

            newsock.Bind(ip);
            ViewModel vm  = ViewModel.getInstance();
            IOT       iot = IOT.getInstance();
            string    value;
            string    value2;

            while (true)
            {
                IPEndPoint sender = new IPEndPoint(IPAddress.Any, 0);
                EndPoint   Remote = (EndPoint)(sender);
                recv = newsock.ReceiveFrom(data, ref Remote);
                msg  = Encoding.ASCII.GetString(data, 0, recv);
                msg  = 提取数据(msg);
                this.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Input, new Action(() =>
                {
                }));

                if (msg != null)
                {
                    if (iot.Json_取数据包类型(msg) == "data")
                    {
                        if (iot.Json_取节点地址(msg) == iot.XML_获取设备节点信息("无线温度采集").nodeaddr)
                        {
                            if (iot.Json_取数值类型(msg) == "singledata" || iot.Json_取数值类型(msg) == "multidata")
                            {
                                value = iot.Json_取数值(msg, "temperature");
                                this.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Input, new Action(() =>
                                {
                                    vm.温度表.Add(new Model.温度表(value));
                                    vm.gauge.当前温度 = double.Parse(value);
                                    if (MainWindow.line1 != null)
                                    {
                                        MainWindow.line1.DataPoints = chartdata.addPoint_温度(double.Parse(value), Model.序号_温度);
                                    }
                                }));
                            }
                            else if (iot.Json_取数值类型(msg) == "querylimit")
                            {
                                value = iot.Json_取报警界限(msg, "temperature");
                                this.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Input, new Action(() =>
                                {
                                    vm.gauge.温度_下限 = value.Split(',')[0];
                                    vm.gauge.温度_上限 = value.Split(',')[1];
                                }));
                            }
                            else if (iot.Json_取数值类型(msg) == "alarm")
                            {
                                this.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Input, new Action(() =>
                                {
                                    vm.温度报警表.Add(new Model.温度报警表("OutOfRange", "温度"));
                                }));
                            }
                        }
                        else if (iot.Json_取节点地址(msg) == iot.XML_获取设备节点信息("无线温湿度采集").nodeaddr)
                        {
                            if (iot.Json_取数值类型(msg) == "singledata" || iot.Json_取数值类型(msg) == "multidata")
                            {
                                value  = iot.Json_取数值(msg, "temperature");
                                value2 = iot.Json_取数值(msg, "humidity");
                                this.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Input, new Action(() =>
                                {
                                    vm.温湿度表.Add(new Model.温湿度表(value, value2));
                                    MainWindow.line2_1.DataPoints = chartdata.addPoint_温湿度_温度(double.Parse(value), Model.序号_温湿度);
                                    MainWindow.line2_2.DataPoints = chartdata.addPoint_温湿度_湿度(double.Parse(value2), Model.序号_温湿度);
                                }));
                            }
                            else if (iot.Json_取数值类型(msg) == "querylimit")
                            {
                                value  = iot.Json_取报警界限(msg, "temperature");
                                value2 = iot.Json_取报警界限(msg, "humidity");
                                this.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Input, new Action(() =>
                                {
                                    vm.gauge.温湿度_温度_下限 = value.Split(',')[0];
                                    vm.gauge.温湿度_温度_上限 = value.Split(',')[1];
                                    vm.gauge.温湿度_湿度_下限 = value2.Split(',')[0];
                                    vm.gauge.温湿度_湿度_上限 = value2.Split(',')[1];
                                }));
                            }
                            else if (iot.Json_取数值类型(msg) == "alarm")
                            {
                                this.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Input, new Action(() =>
                                {
                                    vm.温湿度报警表.Add(new Model.温湿度报警表("OutOfRange", "温湿度"));
                                }));
                            }
                        }
                        else if (iot.Json_取节点地址(msg) == iot.XML_获取设备节点信息("无线光照度采集").nodeaddr)
                        {
                            if (iot.Json_取数值类型(msg) == "singledata" || iot.Json_取数值类型(msg) == "multidata")
                            {
                                value = iot.Json_取数值(msg, "illuminance");
                                this.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Input, new Action(() =>
                                {
                                    vm.光照度表.Add(new Model.光照度表(value));
                                    vm.gauge.当前光照度 = double.Parse(value);
                                    MainWindow.line3.DataPoints = chartdata.addPoint_光照(double.Parse(value), Model.序号_光照度);
                                }));
                            }
                            else if (iot.Json_取数值类型(msg) == "querylimit")
                            {
                                value = iot.Json_取报警界限(msg, "illuminance");
                                this.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Input, new Action(() =>
                                {
                                    vm.gauge.光照度_下限 = value.Split(',')[0];
                                    vm.gauge.光照度_上限 = value.Split(',')[1];
                                }));
                            }
                            else if (iot.Json_取数值类型(msg) == "alarm")
                            {
                                this.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Input, new Action(() =>
                                {
                                    vm.光照度报警表.Add(new Model.光照度报警表("OutOfRange", "光照度"));
                                }));
                            }
                        }
                        else
                        {
                        }
                    }
                }
            }
        }
Example #18
0
        public void 开启光照连续取样()
        {
            NodeInfo TheNode = XML_获取设备节点信息("无线光照度采集");

            CM_IOT_IDC_StartContinuousSampling(CM_HANDLE, int.Parse(ViewModel.getInstance().model.nvsid), TheNode.netid, TheNode.nodeaddr, 1000, 1);
        }
Example #19
0
        public void 光照单次取样()
        {
            NodeInfo TheNode = XML_获取设备节点信息("无线光照度采集");

            CM_IOT_IDC_Sampling(CM_HANDLE, int.Parse(ViewModel.getInstance().model.nvsid), TheNode.netid, TheNode.nodeaddr);
        }
Example #20
0
 public setting()
 {
     InitializeComponent();
     this.DataContext   = ViewModel.getInstance();
     themes.ItemsSource = ThemeManager.GetThemes();
 }