コード例 #1
0
 private void MasterItems_Tick(object sender, EventArgs e)
 {
     if (socketClient != null)
     {
         BLLCommon.SendToServer(CS_AskReply.ClientAskGroupStatus, Properties.Settings.Default.DTUIndex, Convert.ToByte(0xff), Convert.ToByte(0xff), BitConverter.GetBytes(1));
     }
 }
コード例 #2
0
 public void SendReadPackStatus()
 {
     if (socketClient != null)
     {
         BLLCommon.SendToServer(CS_AskReply.ClientAskPackStatus, Properties.Settings.Default.DTUIndex, Convert.ToByte((int)MasterIndex - 1), Convert.ToByte((int)PackIndex - 1), BitConverter.GetBytes(1));
     }
 }
コード例 #3
0
ファイル: ViewModel.cs プロジェクト: wuhudage/BMSCloud_Client
 public void ExcuteTimerCust_Tick(object sender, EventArgs e)
 {
     if (socketClient != null)
     {
         BLLCommon.SendToServer(CS_AskReply.ClientAskCust, Convert.ToByte(0xff), Convert.ToByte(0xff), Convert.ToByte(0xff), BitConverter.GetBytes(1));
     }
 }
コード例 #4
0
 private void ItemDetail_Tick(object sender, EventArgs e)
 {
     if (socketClient != null)
     {
         BLLCommon.SendToServer(CS_AskReply.ClientAskPack, Properties.Settings.Default.DTUIndex, Convert.ToByte(packGroupIndex), Convert.ToByte(packIndex), BitConverter.GetBytes(1));
     }
 }
コード例 #5
0
 private void MasterDetail_Tick(object sender, EventArgs e)
 {
     if (socketClient != null)
     {
         BLLCommon.SendToServer(CS_AskReply.ClientAskGroup, Properties.Settings.Default.DTUIndex, Convert.ToByte(packGroupIndex), Convert.ToByte(0xff), BitConverter.GetBytes(1));
         Thread.Sleep(100);
         BLLCommon.SendToServer(CS_AskReply.ClientAskPackStatus, Properties.Settings.Default.DTUIndex, Convert.ToByte(packGroupIndex), Convert.ToByte(0xff), BitConverter.GetBytes(1));
     }
 }
コード例 #6
0
        /// <summary>
        /// 发送读取历史信息命令
        /// </summary>
        /// <param name="_selectIndex">0-询问Master信息,1-询问Pack信息</param>
        public void SendReadHistoryCommand(int _selectIndex)
        {
            if (socketClient != null)
            {
                List <byte> SendTimeList = new List <byte> {
                };
                SendTimeList.AddRange(BitConverter.GetBytes(DataRange));
                SendTimeList.AddRange(BLLCommon.DateTimeToBytes(StartTime));
                SendTimeList.AddRange(BLLCommon.DateTimeToBytes(EndTime));
                if (_selectIndex == 0)
                {
                    BLLCommon.SendToServer(CS_AskReply.ClientAskGroup, Properties.Settings.Default.DTUIndex, Convert.ToByte((int)MasterIndex - 1), 0xff, SendTimeList.ToArray());
                }

                else
                {
                    BLLCommon.SendToServer(CS_AskReply.ClientAskPack, Properties.Settings.Default.DTUIndex, Convert.ToByte((int)MasterIndex - 1), Convert.ToByte((int)packIndex - 1), SendTimeList.ToArray());
                }
            }
            BLLCommon.ShowWaitWindow();
        }
コード例 #7
0
ファイル: ViewModel.cs プロジェクト: wuhudage/BMSCloud_Client
        private void SendControl()
        {
            if (socketClient != null)
            {
                List <byte> sendControl = new List <byte> {
                    0x7E, 0x27, 0x00, 0x46, 0x45, 0x00, 0x04
                };
                sendControl.Add(infoFlag);
                sendControl.Add(0x00);
                sendControl.Add(0x80);
                if (false)
                {
                    //sendControl.Add(0x10);
                }
                else
                {
                    sendControl.Add(0x1f);
                }
                int sumControl = 0;
                for (int i = 1; i < sendControl.Count; i++)
                {
                    sumControl += sendControl[i];
                }
                sendControl.Add(Convert.ToByte(sumControl & 0x00ff));
                sendControl.Add(0x0D);

                BLLCommon.SendToServer(CS_AskReply.ClientControl, Properties.Settings.Default.DTUIndex, 0xff, 0xff, sendControl.ToArray());
            }
            infoFlag++;
            if (infoFlag == 0xA4)
            {
                infoFlag = 0xA1;
                _timer.Dispose();
                System.Windows.Application.Current.Dispatcher.Invoke(new Action(delegate()
                {
                    BLLCommon.CloseWaitWindow(false);
                    DXMessageBox.Show("已下发紧急操作命令!", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
                }));
            }
        }
コード例 #8
0
ファイル: ViewModel.cs プロジェクト: wuhudage/BMSCloud_Client
        public void SocketEventHandler(object sender, EventArgs e)
        {
            SocketEvent evt = e as SocketEvent;

            if (evt == null)
            {
                return;
            }
            switch (evt.eventType)
            {
            case SocketEventType.StartEvent:

                break;

            case SocketEventType.ConnectEvent:

                break;

            case SocketEventType.ReceEvent:
                byte remark = evt.remark;
                if (remark == CS_AskReply.ClientReplyGroup)
                {
                    if (modelIndex == 2 || modelIndex == 4)
                    {
                        if (FuncDoAction != null)
                        {
                            System.Windows.Application.Current.Dispatcher.Invoke(FuncDoAction, evt.message, remark);
                        }
                    }
                }
                else if (remark == CS_AskReply.ClientReplyPackStatus)
                {
                    if (modelIndex == 2 || modelIndex == 4)
                    {
                        if (FuncDoAction != null)
                        {
                            System.Windows.Application.Current.Dispatcher.Invoke(FuncDoAction, evt.message, remark);
                        }
                    }
                }
                else if (remark == CS_AskReply.ClientReplyGroupStatus)
                {
                    if (modelIndex == 1)
                    {
                        if (FuncDoAction != null)
                        {
                            System.Windows.Application.Current.Dispatcher.Invoke(FuncDoAction, evt.message, remark);
                        }
                    }
                }
                else if (remark == CS_AskReply.ClientReplyPack)
                {
                    if (modelIndex == 3 || modelIndex == 4)
                    {
                        if (FuncDoAction != null)
                        {
                            System.Windows.Application.Current.Dispatcher.Invoke(FuncDoAction, evt.message, remark);
                        }
                    }
                }
                else if (remark == CS_AskReply.ServerAsk)
                {
                    BLLCommon.SendToServer(CS_AskReply.ServerReply, 0xffff, 0xff, 0xff, System.Text.Encoding.ASCII.GetBytes("0n"));
                }
                else if (remark == CS_AskReply.ClientReplyCust)
                {
                    System.Windows.Application.Current.Dispatcher.Invoke(() =>
                    {
                        DataTable dtCust = evt.message as DataTable;
                        foreach (DataRow item in dtCust.Rows)
                        {
                            CustInfoModel CIM = null;
                            for (int i = 0; i < CustListSource.Count; i++)
                            {
                                if (CustListSource[i].CustId == Convert.ToInt32(item["cust_id"]))
                                {
                                    CIM = CustListSource[i];
                                    break;
                                }
                            }

                            if (CIM == null)
                            {
                                CustListSource.Add(new CustInfoModel(
                                                       Convert.ToInt32(item["cust_id"]),
                                                       Convert.ToInt32(item["group_num"]),
                                                       Convert.ToInt32(item["pack_num"]),
                                                       item["cust_name"].ToString(),
                                                       item["cust_status"].ToString(),
                                                       Convert.ToByte(item["cust_fault"])
                                                       ));
                            }
                            else
                            {
                                CIM.CustId     = Convert.ToInt32(item["cust_id"]);
                                CIM.GroupNum   = Convert.ToInt32(item["group_num"]);
                                CIM.PackNum    = Convert.ToInt32(item["pack_num"]);
                                CIM.CustName   = item["cust_name"].ToString();
                                CIM.CustStatus = item["cust_status"].ToString();
                                CIM.CustFault  = Convert.ToByte(item["cust_fault"]);

                                if (CIM.CustId == Properties.Settings.Default.DTUIndex)
                                {
                                    //刷新当前状态栏数据
                                    FuncUpdateStatus(CIM);
                                }
                            }
                        }
                    });
                }
                else
                {
                    System.Windows.Application.Current.Dispatcher.Invoke(() =>
                    {
                        BLLCommon.CloseWaitWindow(true);
                    });
                }

                break;

            case SocketEventType.SendEvent:

                break;

            case SocketEventType.DisconnectEvent:
                if (socketClient != null)
                {
                    socketClient.Stop();
                    if (FuncRefershOffLine != null)
                    {
                        FuncRefershOffLine(true);
                    }
                    socketClient = null;
                    ExcuteTimer.Stop();
                    ExcuteTimerCust.Stop();
                }
                break;

            case SocketEventType.StopEvent:
                break;
            }
        }