public void execMsgFunc(WinMsg msg)
        {
            switch (msg.type)
            {
                case WinMsgType.msJumpHeartStart:

                    break;
                case WinMsgType.mwLinkPlcOK:
                    {
                        topPanel.sendMsgToWinFunc(msg);
                    }
                    break;
                case WinMsgType.mwLinkPlcError:
                    {
                        SCharKeyPanel.hide();
                        SUserPanel.hide();
                        SCalcPanel.hide();
                        SLoadConfFilePanel.hide();
                        SSaveConfFilePanel.hide();
                        topPanel.sendMsgToWinFunc(msg);
                    }
                    break;
                case WinMsgType.mwAccessLower:
                    {
                        topPanel.sendMsgToWinFunc(msg);
                    }
                    break;
                case WinMsgType.mwUserNull:
                    {
                        //toolPanel.getWinMsgHandle(WinMsgType.mwUserNull, null);
                        topPanel.sendMsgToWinFunc(msg);
                    }
                    break;
                case WinMsgType.mwLogInOK:
                    {
                        //toolPanel.getWinMsgHandle(WinMsgType.mwLogInOK, null);
                        //toolPanel.setCurUser();
                        SUserSetPanel.setUserState();
                        topPanel.sendMsgToWinFunc(msg);
                        recUnit ergObj = new recUnit("LogIn", DateTime.Now, recType.logType);
                        valmoWin.eventMgr.msgSave(ergObj);
                        valmoWin.refresh();
                        SUserPanel.LoginInit();
                        //if (dv.users.curUser.accessLevel >= 3)
                        //    mainPanel.interpretorPage1.getAccessFunc();
                        //Program.ctrls.mainPanel.interpretor.interpretorPage.loadOkHandle();
                    }
                    break;
                case WinMsgType.mwNoDog:
                    {
                        MessageBox.Show("请插入超级狗!");
                    }
                    break;
                case WinMsgType.mwLogOut:
                    {
                        recUnit ergObj = new recUnit("LogOut", msg.pStr, DateTime.Now, recType.logType);
                        valmoWin.eventMgr.msgSave(ergObj);
                        //toolPanel.setCurUser();
                        SUserSetPanel.setUserState();
                        topPanel.sendMsgToWinFunc(msg);
                        valmoWin.refresh();
                        //mainPanel.quitToNewPage();
                        UserCtrl.LogOut();
                    }
                    break;
                case WinMsgType.mwPidClear:
                    {

                    }
                    break;
                case WinMsgType.mwMsgNull:
                    {

                    }
                    break;
                case WinMsgType.mwJumpHeartErr:
                    {
                        topPanel.sendMsgToWinFunc(msg);
                    }
                    break;
                case WinMsgType.mwJumpHeartRetart:
                    {
                        topPanel.sendMsgToWinFunc(msg);
                    }
                    break;
                case WinMsgType.mwMsg:
                    {
                        mainPanel.overViewPage1.eventRecord.refreshEvent();
                    }
                    break;
                case WinMsgType.mwRelink:
                    linkPlcPanel.active = true;
                    topPanel.sendMsgToWinFunc(msg);
                    break;
                #region //保存信息
                case WinMsgType.mwMsgSave:
                    {
                        eventMgr.saveToFile();
                        //valmoWin.ds.SPCSave();
                    }
                    break;
                #endregion
            }
        }
        /// <summary>
        /// 产生警是记录
        /// </summary>
        /// <param name="erObj"></param>
        public void msgSave(recUnit erObj)
        {
            itemsLst.Insert(0, erObj);

            valmoWin.execHandle(opeOrderType.winMsg, new WinMsg(WinMsgType.mwMsg));

            if (itemsLst.Count - countFs > 50)
            {
                saveToFile();
            }
        }
 /// <summary>
 /// 读取事件记录
 /// </summary>
 public void loadMessageFromFile()
 {
     FileStream fs = new FileStream(@"conf\msgRecord.vm", FileMode.OpenOrCreate);
     byte[] buffer = new byte[120];
     while (fs.Read(buffer, 0, 120) > 0)
     {
         string str = System.Text.Encoding.Default.GetString(buffer);
         recUnit itemUnit = new recUnit(str);
         if (itemUnit.serialNum != "error")
         {
             itemsLst.Insert(0,itemUnit);
             countFs++;
         }
     }
     fs.Close();
 }
        public void addParamMsg(string serialNum, DateTime dtStart, double oldValue, double newValue, recType type = recType.operateType)
        {
            string ergSerialNum = "--";
            if (serialNum != null)
                ergSerialNum = serialNum;
            string userName = valmoWin.dv.users.curUser.name;
            int plateNum = valmoWin.dv.getCurPlateNr();
            recUnit erObj = new recUnit(serialNum, userName, dtStart, valmoWin.sNullTime, plateNum, oldValue, newValue, type);
            msgSave(erObj);

            valmoWin.refresh();
        }
 public void addParamMsg(objUnit obj, double oldValue, recType type)
 {
     string ergSerialNum = "--";
     if (obj.serialNum != null)
         ergSerialNum = obj.serialNum;
     string userName = valmoWin.dv.users.curUser.name;
     if (userName == "null")
         userName = "******";
     DateTime dtStart = DateTime.Now;
     int plateNum = valmoWin.dv.getCurPlateNr();
     double newValue = obj.valueNew;
     recUnit erObj = new recUnit(ergSerialNum, userName, dtStart, valmoWin.sNullTime, plateNum, oldValue, newValue, type);
     msgSave(erObj);
 }
        public void setValue(recUnit ErObj,int lstNo)
        {
            btnHelp.Visibility = Visibility.Hidden;
            lstNr = lstNo;
            lbSerialNum.Foreground = Brushes.Black;
            //if (lstNo % 2 == 1)
            //    cvsMain.Background = Bg2;
            //else
            //    cvsMain.Background = Brushes.Transparent;
            if (ErObj != null)
            {
                switch (ErObj.type)
                {
                    case recType.alarmType:
                        lbSerialNum.Content = "A" + ErObj.serialNum.Substring(3,3);
                        imgType.Source = (BitmapImage) App.Current.TryFindResource("imgA");
                        btnHelp.Visibility = Visibility.Visible;
                        break;
                    case recType.logType:
                        lbSerialNum.Content = ErObj.serialNum;
                        imgType.Source = (BitmapImage)App.Current.TryFindResource("imgL");
                        break;
                    case recType.operateType:
                        lbSerialNum.Content = ErObj.serialNum;
                        imgType.Source = (BitmapImage)App.Current.TryFindResource("imgM");
                        break;
                    case recType.sysType:
                        lbSerialNum.Content = "S" + ErObj.serialNum.Substring(3,3);
                        imgType.Source = (BitmapImage)App.Current.TryFindResource("imgS");
                        break;
                }
                lbUserName.Content = ErObj.userName;
                if (ErObj.serialNum != null)
                {
                    string objDis = valmoWin.dv.getCurDis(ErObj.serialNum,(int)ErObj.oldValue,(int)ErObj.newValue);
                    if (objDis != "null" && objDis != null)
                    {
                        lbDis.Content = objDis;
                    }
                    else
                    {
                        lbDis.Content = "";
                    }
                }
                else
                    lbDis.Content = "";
                lbDtStart.Content = ErObj.dtStart.ToString("yyyy.MM.dd HH:mm:ss");
                if (ErObj.type == recType.operateType || ErObj.type == recType.logType)
                    lbDtEnd.Content = "";
                else
                {
                    if (ErObj.dtEnd.Year == 1)
                    {
                        for (int i = 0; i < lstWinMsgCtrl.curActiveAlmObjLst.Count; i++)
                        {
                            if (lstWinMsgCtrl.curActiveAlmObjLst[i].dtStart == ErObj.dtStart && ErObj.type == lstWinMsgCtrl.curActiveAlmObjLst[i].type)
                            {
                                lbSerialNum.Foreground = Brushes.Red;
                                break;
                            }
                        }
                        lbDtEnd.Content = "";
                    }
                    else
                    {
                        lbDtEnd.Content = ErObj.dtEnd.ToString("yyyy.MM.dd hh:mm:ss");
                    }
                }
                lbPalteNum.Content = ErObj.plateNums;
                if (ErObj.type == recType.operateType)
                {
                    lbOldValue.Content = ErObj.oldValue;
                    lbNewValue.Content = ErObj.newValue;
                }
                else
                {
                    lbOldValue.Content = "";
                    lbNewValue.Content = "";
                }
            }
            else
            {
                lbSerialNum.Content = "";
                lbUserName.Content = "";
                lbDis.Content = "";
                lbDtStart.Content = "";
                lbDtEnd.Content = "";
                lbPalteNum.Content = "";
                lbOldValue.Content = "";
                lbNewValue.Content = "";
                imgType.Source = null;
            }

            erObj = ErObj;
        }