예제 #1
0
        public void processReceivedData(byte[] replyData)
        {
            string msg = Encoding.ASCII.GetString(replyData);

            if (msg.Length == 7 && msg.Substring(0, 1).Equals("t"))
            {
                BmobWindows bmobWindows = CloudServiceHelper.BmobBuilder();
                int         lowValue    = int.Parse(msg.Substring(1, 2));
                int         highValue   = int.Parse(msg.Substring(4, 2));
                int         value       = (lowValue + highValue) / 2;
                bool        humid       = msg.Substring(6, 1).Equals("s") ? true : false;


                KyOperation kyOperation = new KyOperation(value, humid);
                kyOperation.objectId = "429af4fea3";
                bmobWindows.UpdateTaskAsync(kyOperation);
                KyCommand command = new KyCommand();
                bmobWindows.Get <KyCommand>("KyCommand", "6402c5a401", (result, ex) =>
                {
                    if (ex == null)
                    {
                        if (result.isOpenedLed.Get())
                        {
                            _tcpClient.Send("opled");
                            result.isOpenedLed = false;
                            bmobWindows.UpdateTaskAsync(result);
                        }
                    }
                });
            }
        }
예제 #2
0
        public void stopCloudData()
        {
            KyOperation kyOperation = new KyOperation();

            kyOperation.isOpened = false;
            kyOperation.objectId = "429af4fea3";
            BmobWindows bmobWindows = CloudServiceHelper.BmobBuilder();

            bmobWindows.UpdateTaskAsync(kyOperation);
        }
        private void DataTimer_Tick(object sender, EventArgs e)
        {
            Console.WriteLine("定时器");
            BmobWindows bmobWindows = CloudServiceHelper.BmobBuilder();

            bmobWindows.Get <CloudControl>("CloudControl", "W2obDDDL", (result, ex) =>
            {
                if (ex == null)
                {
                    if (result.deployCollectOpened.Get())
                    {
                        PresetInfo.StartAutoCollect = true;
                        if (!isWorking)
                        {
                            isWorking = true;
                            _commPresenter.DeviceGatherStart(OperateType.Gather);
                        }
                        CloudControl cloudControl       = new CloudControl();
                        cloudControl.objectId           = "W2obDDDL";
                        cloudControl.cloudCollectOpened = true;

                        if (currentCollectNum == 0)
                        {
                            cloudControl.cloudCollectProgress = 0;
                        }
                        else
                        {
                            int value = currentCollectNum * 100 / currentCollectSumNum;
                            cloudControl.cloudCollectProgress = value;
                            Console.WriteLine("当前进度:" + value);
                        }
                        bmobWindows.UpdateTaskAsync(cloudControl);
                        Console.WriteLine("数据发送完毕");
                    }
                    else
                    {
                        PresetInfo.StartAutoCollect = false;
                        isWorking = false;
                    }
                }
            });
        }
예제 #4
0
 public MainWindow()
 {
     InitializeComponent();
     _presenter          = new Presenter(this);
     _cloudServiceHelper = new CloudServiceHelper();
 }