Пример #1
0
        /// <summary>
        /// 重新嵌入一个页面
        /// </summary>
        /// <param name="content"></param>
        private void Insert_SO(string content)
        {
            string protocolFolder = string.Empty;

            if (currentProtocol == XDCProtocolType.NDC)
            {
                protocolFolder = "NDC";
            }
            else
            {
                protocolFolder = "DDC";
            }
            string filePath = XDCUnity.eCATPath + @"\XDC\" + protocolFolder + @"\Scripts\Screen\Host\000\" + content + ".txt";

            if (!File.Exists(filePath))
            {
                return;
            }
            string        txt    = XDCUnity.GetTxtFileText(filePath);
            List <object> result = XDCUnity.ScreenOperator.GetView(txt);

            if (result != null && result.Count > 0)
            {
                ExcuteScreenCmd(result);
            }
        }
Пример #2
0
 private void saveToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(rtb_Text.Text.Trim()))
     {
         XDCUnity.WriteTextFileText(currentScreenPath, rtb_Text.Text);
     }
 }
Пример #3
0
        private void ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ToolStripMenuItem tmi = sender as ToolStripMenuItem;

            switch (tmi.Text)
            {
            case "CollapseAll":
            {
                treeView1.CollapseAll();
            }
            break;

            case "Collapse":
            {
                treeView1.SelectedNode.Parent.Collapse();
            }
            break;

            case "Run":
            {
                XDCUnity.OpenTextFileWith("", treeView1.SelectedNode.Name);
            }
            break;

            case "AddToNewPack":
            {
            }
            break;

            default:
                break;
            }
        }
Пример #4
0
 private void ShowDetailStateOrScreen(string FieldName, string FieldValue)
 {
     if (FieldName.Contains("Screen"))
     {
         string screenPath = XDCUnity.eCATPath + @"\XDC\" + folderName + @"\Scripts\Screen" + XDCUnity.CurrentResourceIndex + @"\Host\000\" + FieldValue + ".txt";
         if (File.Exists(screenPath))
         {
             string           screenText       = XDCUnity.GetTxtFileText(screenPath);
             Form_ScreenParse form_ScreenParse = new Form_ScreenParse(screenText, currentProtocolType, FieldValue + ".txt");
             form_ScreenParse.Show();
         }
         else
         {
             MessageBox.Show("Do note Exists Screen File:" + screenPath);
         }
     }
     else if (FieldName.Contains("State"))
     {
         string statePath = XDCUnity.eCATPath + @"\XDC\" + folderName + @"\Scripts\State" + XDCUnity.CurrentResourceIndex + @"\Host\" + FieldValue + ".txt";
         if (File.Exists(statePath))
         {
             string        stateText  = XDCUnity.GetTxtFileText(statePath);
             Form_MsgDebug form_Debug = new Form_MsgDebug(stateText, currentProtocolType, DataType.State, FieldValue + ".txt");
             form_Debug.Show();
         }
         else
         {
             MessageBox.Show("Do note Exists State File:" + statePath);
         }
     }
 }
Пример #5
0
        void Program_SendMsgToGM01_Event(object socket, string msg)
        {
            Socket tempSock = socket as Socket;

            if (tempSock != null)
            {
                string headContext = string.Empty;
                byte[] msgBytes    = XDCUnity.EnPackageMsg(msg, TcpHead.L2L1, ref headContext);
                tempSock.Send(msgBytes);
            }
        }
Пример #6
0
        /// <summary>
        /// 启动eCAT
        /// </summary>
        private void StarteCATFunc()
        {
            #region start
            CheckeCATPath();

            CheckTrueBackPath();

            XDCUnity.StarteCAT();

            #endregion
        }
Пример #7
0
        private void checkAllStateToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ToolStripMenuItem tmi = (ToolStripMenuItem)sender;

            switch (tmi.Text)
            {
            case "CheckAllState":
            {
                new Form_StateCheck(stateScan_NDC, stateScan_DDC).Show();
            }
            break;

            case "Log":
            {
                XDCUnity.OpenPath(XDCUnity.eCATPath + "\\log");
            }
            break;

            case "XDC\\NDC":
            {
                XDCUnity.OpenPath(XDCUnity.eCATPath + "\\XDC\\NDC\\Scripts");
            }
            break;

            case "XDC\\DDC":
            {
                XDCUnity.OpenPath(XDCUnity.eCATPath + "\\XDC\\DDC\\Scripts");
            }
            break;

            case "TransactionFlow":
            {
                XDCUnity.OpenPath(XDCUnity.eCATPath + "\\TransactionFlow\\XDC");
            }
            break;

            case "Config":
            {
                XDCUnity.OpenPath(XDCUnity.eCATPath + "\\Config");
            }
            break;

            case "Resource":
            {
                XDCUnity.OpenPath(XDCUnity.eCATPath + "\\Resource");
            }
            break;

            default:
                break;
            }
        }
Пример #8
0
        void Program_SendMsgToeCATEvent(object socket, XDCMessage msg)
        {
            Socket tempSock = socket as Socket;

            if (tempSock != null)
            {
                string headContext = string.Empty;
                byte[] msgBytes    = XDCUnity.EnPackageMsg(msg.MsgASCIIString, TcpHead.L2L1, ref headContext);
                tempSock.Send(msgBytes);
                this.lsb_Log_GM01.Items.Add(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss fff") + " :" + "Send(" + (msg.MsgASCIIString.Length).ToString().PadLeft(4, '0') + ") : " + msg.MsgASCIIString);
            }
            this.lsb_Log_GM01.TopIndex = lsb_Log_GM01.Items.Count - (int)(lsb_Log_GM01.Height / lsb_Log_GM01.ItemHeight);
        }
Пример #9
0
        /// <summary>
        /// 获取SP的错误吗
        /// </summary>
        private void GetSPlogViewCode()
        {
            if (!File.Exists(logViewPaht))
            {
                //MessageBox.Show("Can not find SP path.");
                return;
            }
            string cnText_sp = XDCUnity.ReadIniData("DevFail", txt_Code.Text.Trim(), "", logViewPaht);
            string enText_sp = XDCUnity.ReadIniData("DevFail_ENG", txt_Code.Text.Trim(), "", logViewPaht);

            lbl_SP_CN.Text = cnText_sp;
            lbl_SP_EN.Text = enText_sp;
        }
Пример #10
0
 /// <summary>
 /// 保存内容
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void SaveToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (DialogResult.OK == MessageBox.Show("Sure to Save?", "XDC Virtual Host", MessageBoxButtons.OKCancel))
     {
         if (XDCUnity.WriteTextFileText(currentFilePath, rtb_Msg.Text.Trim()))
         {
             MessageBox.Show("Save Successed.");
         }
         else
         {
             MessageBox.Show("Save Failed.");
         }
     }
 }
Пример #11
0
        private void Rtb_Msg_DragDrop(object sender, DragEventArgs e)
        {
            Array fileName = (Array)e.Data.GetData(DataFormats.FileDrop);

            if (null != fileName)
            {
                rtb_Msg.Text = XDCUnity.GetTxtFileText(fileName.GetValue(0).ToString());
            }
            else
            {
                rtb_Msg.Text = e.Data.GetData(DataFormats.Text).ToString();
            }
            e.Effect = DragDropEffects.None;
            BeginPars();
        }
 private void Form_Left_SubFormEvent(object subControl, XDCProtocolType protocolType, DataType dataType)
 {
     {
         string text = XDCUnity.GetTxtFileText(subControl.ToString());
         //双击树节点,将数据传至主窗体并格式化显示
         if (dataType == DataType.Screen)
         {
             Form_ScreenParse form_ScreenParse = new Form_ScreenParse(text, protocolType, subControl.ToString());
             form_ScreenParse.Show();
         }
         else
         {
             form_MsgDebug.ParsFromSubForm(text, protocolType, dataType, subControl.ToString());
         }
     }
 }
Пример #13
0
 private void treeView1_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
 {
     if (!File.Exists(e.Node.Name) ||
         (!e.Node.Name.ToLower().EndsWith(".txt") &&
          !e.Node.Name.ToLower().EndsWith(".ini") &&
          !e.Node.Name.ToLower().EndsWith(".xml") &&
          !e.Node.Name.ToLower().EndsWith(".html") &&
          !e.Node.Name.ToLower().EndsWith(".log") &&
          !e.Node.Name.ToLower().EndsWith(".bat") &&
          !e.Node.Name.ToLower().EndsWith(".htm")))
     {
         return;
     }
     ShowStatus(e.Node.Name);
     //OpenTextFileWith("notepad++.exe", e.Node.Name);
     XDCUnity.OpenTextFileWith("notepad++.exe", e.Node.Name);
 }
Пример #14
0
        private void Form_Main_Click(object sender, EventArgs e)
        {
            this.WindowState = FormWindowState.Minimized;
            string path        = ((ToolStripMenuItem)sender).ToolTipText;
            string currentPath = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;

            currentPath = currentPath.Substring(0, currentPath.LastIndexOf('\\'));
            if (!string.IsNullOrEmpty(path) &&
                path.Length > 2 &&
                path[1].ToString().Equals(":"))
            {
                //路径是类似c:\dd\..\..这样的绝对路径
                XDCUnity.OpenPath(path);
            }
            else
            {
                //相对路径
                XDCUnity.OpenPath(currentPath + path);
            }
        }
Пример #15
0
        private void btn_Next_Click(object sender, EventArgs e)
        {
            Button currentButton = (Button)sender;

            if (string.IsNullOrEmpty(currentScreenPath))
            {
                return;
            }
            int    flit_1       = currentScreenPath.LastIndexOf('\\');
            int    flit_2       = currentScreenPath.LastIndexOf('.');
            int    newScreenNum = int.Parse(currentScreenPath.Substring(flit_1 + 1, flit_2 - flit_1 - 1));
            string newPath      = string.Empty;

            switch (currentButton.Name)
            {
            case "btn_Pre":
            {
                //newPath = currentScreenPath.Substring(0, flit_1 + 1) + string.Format("{0:D3}", newScreenNum - 1) + ".txt";
                newPath = GetNextScreenNum(currentScreenPath, flit_1, newScreenNum, true);
            }
            break;

            case "btn_Next":
            {
                // newPath = currentScreenPath.Substring(0, flit_1 + 1) + string.Format("{0:D3}", newScreenNum + 1) + ".txt";
                newPath = GetNextScreenNum(currentScreenPath, flit_1, newScreenNum, false);
            }
            break;

            default:
                break;
            }


            if (File.Exists(newPath))
            {
                rtb_Text.Text     = XDCUnity.GetTxtFileText(newPath);
                currentScreenPath = newPath;
                this.Text         = "ScreenParse - [" + newPath + "]";
            }
        }
Пример #16
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (!File.Exists(txt_LogPath.Text.Trim()))
            {
                return;
            }


            string curProtocol = rbt_DDC.Checked ? "DDC" : "NDC";

            XDCUnity.MessageFormat = rbt_DDC.Checked ? new MessageFormat_DDC() as IMessageFormat : new MessageFormat_NDC() as IMessageFormat;
            string curHost        = rbt_Server_1.Checked ? "Host_1" : "Host_2";
            string opcIniFilePath = string.Empty;
            string iniFileName    = "OperationCodeConfig.ini";

            opcIniFilePath = Environment.CurrentDirectory + @"\Config\Server\" + curProtocol + "\\" + curHost + "\\" + iniFileName;

            ReadLogs(txt_LogPath.Text);
            foreach (KeyValuePair <string, OperationCodeObject> item in OperationDic)
            {
                richTextBox1.AppendText("[" + item.Key.Replace(" ", "_") + "]\r\n");

                XDCUnity.WriteIniData(item.Key.Replace(" ", "_"), "Comment", "{Input Comment}", opcIniFilePath);
                richTextBox1.AppendText("Comment=" + "{ Input Comment}\r\n");

                XDCUnity.WriteIniData(item.Key.Replace(" ", "_"), "FixedMsg", item.Value.ReplyMsg, opcIniFilePath);
                richTextBox1.AppendText("FixedMsg=" + item.Value.ReplyMsg + "\r\n");

                if (!string.IsNullOrEmpty(item.Value.InteractiveMsg))
                {
                    XDCUnity.WriteIniData(item.Key.Replace(" ", "_"), "InteractiveReply", "1", opcIniFilePath);
                    richTextBox1.AppendText("InteractiveReply= \r\n");
                    XDCUnity.WriteIniData(item.Key.Replace(" ", "_"), "FixedInterActiveMsg", item.Value.InteractiveMsg, opcIniFilePath);
                    richTextBox1.AppendText("FixedInterActiveMsg=" + item.Value.InteractiveMsg + "\r\n");
                }

                richTextBox1.AppendText("===========================\r\n");
            }

            MessageBox.Show("Successed.");
        }
Пример #17
0
        private void Pnl_Screen_DragDrop(object sender, DragEventArgs e)
        {
            Array fileName = (Array)e.Data.GetData(DataFormats.FileDrop);

            if (null != fileName)
            {
                rtb_Text.Text = XDCUnity.GetTxtFileText(fileName.GetValue(0).ToString());
            }
            else
            {
                rtb_Text.Text = e.Data.GetData(DataFormats.Text).ToString();
            }
            e.Effect = DragDropEffects.None;


            DrawXDCScreen();
            if (!string.IsNullOrEmpty(rtb_Text.Text.Trim()))
            {
                BegionScreenParse();
            }
        }
Пример #18
0
        private void ProcessSetGroupBox(Control.ControlCollection artControls, string argSection, string argKeyAppendText)
        {
            CurrentIniPath = XDCUnity.CurrentPath + @"\Config\Server\" + ProtocolString + "\\" + CurrentHost + "\\CommonConfig.ini";
            string flag = string.Empty;

            foreach (Control item in artControls)
            {
                flag = "1";;
                if (item.GetType().Name == "CheckBox")
                {
                    if (((CheckBox)item).Checked)
                    {
                        flag = "1";
                    }
                    else
                    {
                        flag = "0";
                    }
                    XDCUnity.WriteIniData(argSection, ((CheckBox)item).Text + argKeyAppendText, flag, CurrentIniPath);
                }
            }
        }
Пример #19
0
 public Form_MsgDebug(string msgText, XDCProtocolType protocolType, DataType dataType = DataType.Message, string subTitle = "", bool isdebug = false)
 {
     InitializeComponent();
     XDCUnity.Initial();
     rtb_Msg.Text        = msgText;
     currentProtocolType = protocolType;
     isDebug             = isdebug;
     if (!string.IsNullOrEmpty(subTitle))
     {
         this.Text += " - [" + subTitle + "]";
     }
     if (protocolType == XDCProtocolType.DDC)
     {
         rb_DDC.Checked = true;
         folderName     = "DDC";
     }
     else
     {
         rb_NDC.Checked = true;
         folderName     = "NDC";
     }
     if (dataType == DataType.Message)
     {
         rb_Message.Checked = true;
     }
     else if (dataType == DataType.State)
     {
         rb_State.Checked = true;
     }
     else if (dataType == DataType.Screen)
     {
         rb_Screen.Checked = true;
     }
     else if (dataType == DataType.Fit)
     {
         rb_Fit.Checked = true;
     }
     BeginPars();
 }
Пример #20
0
        /// <summary>
        /// 启动eCAT-XDC配置
        /// </summary>
        private static void eCATConfigToolFunc()
        {
            #region eCATConfigTool

            //检查eCAT路径
            CheckeCATPath();

            string path = XDCUnity.eCATPath + @"\eCATConfigTool";
            if (File.Exists(path))
            {
                try
                {
                    File.Delete(path);
                }
                catch
                {
                }
            }
            path = XDCUnity.eCATPath + @"\eCATConfigTool.exe";
            XDCUnity.ProcessFile(path);
            #endregion
        }
Пример #21
0
        private void ProcessInitialGroupBox(Control.ControlCollection artControls, string argSection, string argKeyAppendText)
        {
            CurrentIniPath = XDCUnity.CurrentPath + @"\Config\Server\" + ProtocolString + "\\" + CurrentHost + "\\CommonConfig.ini";
            string flag = string.Empty;

            foreach (Control item in artControls)
            {
                flag = string.Empty;
                if (item.GetType().Name == "CheckBox")
                {
                    flag = XDCUnity.ReadIniData(argSection, ((CheckBox)item).Text + argKeyAppendText, "", CurrentIniPath);

                    if (flag.Equals("1"))
                    {
                        ((CheckBox)item).Checked = true;
                    }
                    else
                    {
                        ((CheckBox)item).Checked = false;
                    }
                }
            }
        }
Пример #22
0
        public XDCMessage Format(byte[] msgByte, int msgLength, TcpHead HeadType = TcpHead.NoHead, bool isDebug = false)
        {
            XDCMessage result = new XDCMessage();

            try
            {
                #region EBCDIC
                long blong = 0;
                XDCUnity.PackMsgCode(ref msgByte, ref blong, "Recv", isDebug);
                #endregion
                //0.原字节数组
                result.MsgByteArray = msgByte;

                //2.ASCII字符串
                //2.ASCII字符串
                if (HeadType == TcpHead.L2L1)
                {
                    //L2L1,the len is in index 1
                    int megLen = msgByte[1] + (msgByte[0] << 8);
                    result.MsgASCIIString = Encoding.ASCII.GetString(msgByte, 2, megLen);
                    //result.MsgASCIIString = Encoding.ASCII.GetString(msgByte, 2, msgLength - 2);
                }
                else if (HeadType == TcpHead.L1L2)
                {
                    //L1L2, the len is in index 0
                    int megLen = msgByte[0] + (msgByte[1] << 8);
                    result.MsgASCIIString = Encoding.ASCII.GetString(msgByte, 2, megLen);
                    //result.MsgASCIIString = Encoding.ASCII.GetString(msgByte, 2, msgLength - 2);
                }
                else if (HeadType == TcpHead.L4L3L2L1)
                {
                    int megLen = msgByte[3] + (msgByte[2] << 8) + (msgByte[1] << 16) + (msgByte[0] << 24);
                    result.MsgASCIIString = Encoding.ASCII.GetString(msgByte, 4, megLen);
                    //result.MsgASCIIString = Encoding.ASCII.GetString(msgByte, 4, msgLength - 4);
                }
                else if (HeadType == TcpHead.L4L3L2L1_ASCII)
                {
                    byte[] m_head = new byte[] { msgByte[0], msgByte[1], msgByte[2], msgByte[3] };
                    int    megLen = int.Parse(Encoding.ASCII.GetString(m_head));// msgByte[3] + (msgByte[2] << 8) + (msgByte[1] << 16) + (msgByte[0] << 24);
                    result.MsgASCIIString = Encoding.ASCII.GetString(msgByte, 4, megLen);
                    //result.MsgASCIIString = Encoding.ASCII.GetString(msgByte, 4, msgLength - 4);
                }
                else if (HeadType == TcpHead.L1L2L3L4)
                {
                    int megLen = msgByte[0] + (msgByte[1] << 8) + (msgByte[2] << 16) + (msgByte[3] << 24);;
                    result.MsgASCIIString = Encoding.ASCII.GetString(msgByte, 4, megLen);
                }
                else
                {
                    result.MsgASCIIString = Encoding.ASCII.GetString(msgByte, 0, msgLength);
                }

                char     MsgFS     = '\u001C';//域分隔符
                string[] msgFields = result.MsgASCIIString.Split(MsgFS);

                //3.分解消息得各域的字符数组
                result.MsgASCIIStringFields = msgFields;

                //4.标识
                if (msgFields.Length > 3 && msgFields[3].Length > 0)
                {
                    result.Identification = msgFields[3].Substring(0, 1);
                }
                //5.消息类别
                string tempField_0 = msgFields[0].Length > 3 ? msgFields[0].Substring(2, msgFields[0].Length - 2) : msgFields[0];
                result.MsgType = FormatHelper.ParsMessageClass(tempField_0);

                if (result.MsgType == MessageType.UnSolicitedMessage &&
                    msgFields.Length > 7 && msgFields[7].Length > 0)
                {
                    //操作码
                    result.OperationCode = msgFields[7].Replace(" ", "_");
                    //金额域
                    if (msgFields.Length > 8)
                    {
                        result.AmountField = msgFields[8];
                    }
                    //pan
                    if (msgFields[5].IndexOf('=') > 0)
                    {
                        result.PAN = msgFields[5].Substring(1, msgFields[5].IndexOf('=') - 1);
                    }
                }

                string msgResult = string.Empty;
                result.MsgCommandType = MessageCommandType.Unknow;

                #region 5.判断消息类型

                switch (result.Identification)
                {
                case "1":
                {
                    if (result.MsgType == MessageType.TerminalCommand)
                    {
                        result.MsgCommandType = MessageCommandType.GoInService;
                    }
                }
                break;

                case "2":
                {
                    if (result.MsgType == MessageType.TerminalCommand)
                    {
                        result.MsgCommandType = MessageCommandType.GoOutOfService;
                    }
                }
                break;

                case "3":
                {
                    //NDC
                    if (result.MsgType == MessageType.SolicitedMessage)
                    {
                        result.MsgCommandType = MessageCommandType.NewKeyVerification;
                    }
                    //NeedSendToBothHost.Enqueue(result.MsgBase64String);
                }
                break;

                case "8":
                {
                    //NDC
                    if (result.MsgType == MessageType.SolicitedMessage)
                    {
                        result.MsgCommandType = MessageCommandType.DeviceFault;
                    }
                    if (msgFields.Length > 4 && msgFields[4].Length > 2 && msgFields[4].Substring(0, 2) == "E2")
                    {
                        result.MsgCommandType = MessageCommandType.Reversal;
                    }
                }
                break;

                case "9":
                {
                    if (result.MsgType == MessageType.SolicitedMessage)
                    {
                        result.MsgCommandType = MessageCommandType.ReadyB;
                    }
                }
                break;

                case "B":
                {
                    if (result.MsgType == MessageType.UnSolicitedMessage)
                    {
                        if (msgFields[3].Equals("B0000"))
                        {
                            result.MsgCommandType = MessageCommandType.FullDownLoad;
                            if (!XDCUnity.isFulldownLoadEnqueue)
                            {
                                NeedSendToBothHost.Enqueue(result.MsgASCIIString);
                                XDCUnity.isFulldownLoadEnqueue = true;
                            }
                        }
                        else
                        {
                            result.MsgCommandType = MessageCommandType.NotFullDownLoad;
                        }
                    }
                }
                break;

                case "E":
                {
                    if (result.MsgType == MessageType.UnSolicitedMessage)
                    {
                        //cash handle
                        result.MsgCommandType = MessageCommandType.CashHandler;
                        //NeedSendToBothHost.Enqueue(result.MsgBase64String);
                    }
                }
                break;

                case "F":
                {
                    //NDC
                    if (result.MsgType == MessageType.SolicitedMessage)
                    {
                        //TerminalState
                        result.MsgCommandType = MessageCommandType.TerminalState;
                        //NeedSendToBothHost.Enqueue(result.MsgBase64String);
                    }
                }
                break;

                case "P":
                {
                    if (result.MsgType == MessageType.UnSolicitedMessage &&
                        msgFields[3].Length > 2)
                    {
                        if ("20" == msgFields[3].Substring(1, 2))
                        {
                            result.MsgCommandType = MessageCommandType.SupervisorAndSupplySwitchOFF;
                        }
                        else if ("21" == msgFields[3].Substring(1, 2))
                        {
                            result.MsgCommandType = MessageCommandType.SupervisorAndSupplySwitchON;
                        }
                    }
                }
                break;

                case "":
                {
                    result.MsgCommandType = MessageCommandType.TransactionMessage;
                }
                break;

                default:
                    break;
                }

                #endregion

                //6.LUNO
                if (msgFields.Length > 1 && msgFields[1].Length > 0)
                {
                    if (msgFields[1].Length > 6)
                    {
                        result.LUNO = msgFields[1].Substring(0, 6);
                    }
                    else
                    {
                        result.LUNO = msgFields[1];
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.LogError(this.GetType().Name, "Format Error:" + ex.Message);
            }
            return(result);
        }
Пример #23
0
        private static void FindFinalFS(ref List <ParsRowView> rowViewList, ref List <TemplateView> TvList, ref bool isFoundFS_x, string msgCurrentFieldContent)
        {
            string[] gsGroup = msgCurrentFieldContent.Split(XDCSplictorChar.GS);
            if (gsGroup.Length > 1)
            {
                //GS情况
                FindFinalGS(ref rowViewList, ref TvList, msgCurrentFieldContent);
                //SetFS_GS_(ref rowViewList, TvList, "GS", gsGroup);
            }
            else
            {
                #region 正是当前要找的FS

                int currentContentIndex = 0;
                foreach (TemplateView tvItem in TvList)
                {
                    if (tvItem.FieldName == "ICC data objects (and Further ICC data objects) requested by Central")
                    {
                        #region 生成IC卡数据提示行

                        ParsRowView ic = new ParsRowView();
                        ic.FieldName    = "IC";
                        ic.FieldComment = tvItem.FieldName;
                        rowViewList.Add(ic);

                        #endregion

                        string tempvalueAll = msgCurrentFieldContent.Substring(currentContentIndex, msgCurrentFieldContent.Length - currentContentIndex);
                        string tempAll      = tempvalueAll;
                        string key          = "tagMeaning";
                        bool   isFirst      = true;

                        string sub_4      = tempAll.Substring(0, 4);
                        string sub_2      = tempAll.Substring(0, 2);
                        string tagIniPath = XDCUnity.CurrentPath + @"\Config\Protocol\TagList.ini";
                        string tagMeaning = XDCUnity.ReadIniData(sub_4, key, "", tagIniPath);
                        int    currentLen = -1;
                        string tagName    = string.Empty;
                        while (tempAll.Length > 0)
                        {
                            if (!isFirst)
                            {
                                ParsRowView tg = new ParsRowView();
                                tg.FieldName = "TG";
                                rowViewList.Add(tg);
                            }
                            isFirst    = false;
                            sub_4      = tempAll.Substring(0, 4);
                            sub_2      = tempAll.Substring(0, 2);
                            tagMeaning = XDCUnity.ReadIniData(sub_4, key, "", tagIniPath);
                            currentLen = -1;
                            tagName    = string.Empty;
                            if (!string.IsNullOrEmpty(tagMeaning))
                            {
                                currentLen = 4;
                                tagName    = sub_4;
                            }
                            else
                            {
                                //长度为4的tag找不到,找长度为2的。
                                tagMeaning = XDCUnity.ReadIniData(sub_2, key, "", tagIniPath);
                                if (string.IsNullOrEmpty(tagMeaning))
                                {
                                    break;
                                }
                                currentLen = 2;
                                tagName    = sub_2;
                            }

                            #region 增加行
                            //tagName
                            tempAll = tempAll.Substring(currentLen, tempAll.Length - currentLen);
                            ParsRowView prv_tagName = new ParsRowView();
                            prv_tagName.FieldName    = "TagName";
                            prv_tagName.FieldComment = tagMeaning;
                            prv_tagName.FieldValue   = tagName;
                            rowViewList.Add(prv_tagName);

                            //tagLen
                            string len = tempAll.Substring(0, 2);
                            tempAll = tempAll.Substring(2, tempAll.Length - 2);
                            ParsRowView prv_tagLen = new ParsRowView();
                            prv_tagLen.FieldName    = "ValueLength";
                            prv_tagLen.FieldComment = "Hex";
                            prv_tagLen.FieldValue   = len;
                            rowViewList.Add(prv_tagLen);

                            //tagValue
                            int    valueLen = Convert.ToInt32(len, 16);
                            string value    = tempAll.Substring(0, valueLen * 2);
                            tempAll = tempAll.Substring(valueLen * 2, tempAll.Length - valueLen * 2);
                            ParsRowView prv_tagValue = new ParsRowView();
                            prv_tagValue.FieldName    = "Value";
                            prv_tagValue.FieldComment = "";
                            prv_tagValue.FieldValue   = value;
                            rowViewList.Add(prv_tagValue);
                            #endregion
                        }
                    }
                    else
                    {
                        #region MyRegion
                        ParsRowView prv = new ParsRowView();
                        prv.FieldName = tvItem.FieldName;
                        //加上prv.FieldName == "GS**"的判断,解决显示GS**行而内容又为空的情况。edit by frde 20160106
                        if (/*(prv.FieldName == "GS" || prv.FieldName == "GS**")*/
                            prv.FieldName.StartsWith("GS")
                            /* && msgCurrentFieldContent.Length == currentContentIndex*/)
                        {
                            break;
                        }
                        try
                        {
                            if (tvItem.FieldSize <= 0)
                            {
                                prv.FieldValue = msgCurrentFieldContent.Substring(currentContentIndex, msgCurrentFieldContent.Length - currentContentIndex);
                            }
                            else
                            {
                                prv.FieldValue = msgCurrentFieldContent.Substring(currentContentIndex, tvItem.FieldSize);
                            }
                        }
                        catch
                        {
                            prv.FieldValue = "";
                        }
                        if (tvItem.FieldValue != null)
                        {
                            if (string.IsNullOrEmpty(prv.FieldValue))
                            {
                                prv.FieldComment = "";
                            }
                            else if (tvItem.FieldValue.ContainsKey(prv.FieldValue))
                            {
                                prv.FieldComment = tvItem.FieldValue[prv.FieldValue];
                            }
                            else if (tvItem.FieldValue.ContainsKey("*"))
                            {
                                prv.FieldComment = tvItem.FieldValue["*"];
                            }
                            else
                            {
                                bool isFind = false;
                                foreach (KeyValuePair <string, string> kvpItem in tvItem.FieldValue)
                                {
                                    //&运算
                                    if (kvpItem.Key.Contains("&amp;"))
                                    {
                                        try
                                        {
                                            isFind = true;
                                            string ampValue    = kvpItem.Key.Substring(0, kvpItem.Key.IndexOf("&amp;"));
                                            string ampOperator = kvpItem.Key.Substring(kvpItem.Key.IndexOf("&amp;") + 5, kvpItem.Key.Length - kvpItem.Key.IndexOf("&amp;") - 5);
                                            int    ampResult   = int.Parse(prv.FieldValue) & int.Parse(ampOperator);
                                            if (ampResult.ToString() == ampValue)
                                            {
                                                prv.FieldComment += kvpItem.Value + ";";
                                            }
                                        }
                                        catch
                                        {
                                            prv.FieldComment = "";
                                        }
                                    }
                                }
                                if (!isFind)
                                {
                                    prv.FieldComment = "UnKnow Value";
                                }
                            }
                        }
                        else
                        {
                            prv.FieldComment = "";
                        }
                        rowViewList.Add(prv);

                        if (tvItem.FieldSize <= 0)
                        {
                            currentContentIndex += msgCurrentFieldContent.Length - currentContentIndex;
                        }
                        else
                        {
                            currentContentIndex += tvItem.FieldSize;
                        }
                        #endregion
                    }
                }
                TvList.Clear();
                #endregion
            }
            TvList.Clear();
            isFoundFS_x = false;
        }
Пример #24
0
        public List <ParsRowView> GetView(string parsText)
        {
            List <ParsRowView> result = new List <ParsRowView>();
            //NDC
            string attrProtocolType = "2";
            //State
            string attrDataType = "1";
            string attrKey      = "";

            if (parsText.Contains(" "))
            {
                attrKey = parsText.Substring(0, parsText.IndexOf(" "));
            }
            else
            {
                attrKey = parsText.Substring(0, 1);
            }

            XmlNode cur = XDCUnity.GetNodeDetail(XDCUnity.Root, attrKey, attrProtocolType, attrDataType);

            if (cur == null)
            {
                //NDC OR DDC
                attrProtocolType = "0";
                cur = XDCUnity.GetNodeDetail(XDCUnity.Root, attrKey, attrProtocolType, attrDataType);
            }
            if (cur != null)
            {
                int curIndex = 0;
                foreach (XmlNode item in cur.ChildNodes)
                {
                    TemplateView tv        = new TemplateView();
                    XmlAttribute fieldName = item.Attributes["Name"];
                    XmlAttribute fieldSize = item.Attributes["Size"];
                    ParsRowView  prv       = new ParsRowView();

                    int size;
                    int.TryParse(fieldSize.Value, out size);

                    string tempValue   = "";
                    string tempComment = "";
                    try
                    {
                        tempValue = parsText.Substring(curIndex, size);
                        curIndex += size;
                    }
                    catch
                    {
                        if (parsText.Length - curIndex > 0)
                        {
                            tempValue = parsText.Substring(curIndex, parsText.Length - curIndex);
                        }
                        else
                        {
                            tempValue = "";
                        }
                        tempComment = "Invalid Length";
                        curIndex   += size;
                    }

                    if (string.IsNullOrEmpty(tempComment) && item.HasChildNodes)
                    {
                        bool isFindComment = false;
                        bool isStartFound  = false;
                        foreach (XmlNode commentItem in item.ChildNodes)
                        {
                            string commentValue = commentItem.InnerText;
                            string commentText  = commentItem.Attributes["Comment"].Value;
                            if (tempValue.Equals(commentValue.Trim()) ||
                                commentValue.Trim() == "*")
                            {
                                tempComment   = commentText;
                                isFindComment = true;
                                break;
                            }
                        }
                        if (!isFindComment)
                        {
                            tempComment = "UnKnow Value";
                        }
                    }
                    result.Add(new ParsRowView(fieldName.Value.ToString(), tempValue, tempComment));
                }
                return(result);
            }
            else
            {
                return(null);
            }
        }
Пример #25
0
        private void DDCServerToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ToolStripMenuItem tmi = sender as ToolStripMenuItem;

            switch (tmi.Text)
            {
            case "ATMC":
            case "DDCServer":
            case "DDCServer-2":
            case "NDCServer":
            case "NDCServer-2":
            case "VirtualDualHost":
            {
                isAlreadyNDC_1     = false;
                isAlreadyNDC_2     = false;
                isAlareadyDualHost = false;
                isAlreadyDDC_1     = false;
                isAlreadyDDC_2     = false;
                isATMC             = false;
                foreach (DockContent dockContent in dockPanel1.Contents)
                {
                    if (dockContent.Name.Equals("Form_NDCServer"))
                    {
                        isAlreadyNDC_1 = true;
                    }
                    else if (dockContent.Name.Equals("Form_NDCServer_2"))
                    {
                        isAlreadyNDC_2 = true;
                    }
                    else if (dockContent.Name.Equals("Form_DDCServer"))
                    {
                        isAlreadyDDC_1 = true;
                    }
                    else if (dockContent.Name.Equals("Form_DDCServe2"))
                    {
                        isAlreadyDDC_2 = true;
                    }
                    else if (dockContent.Name.Equals("Form_DualHost"))
                    {
                        isAlareadyDualHost = true;
                    }
                    else if (dockContent.Name.Equals("Form_Managerment"))
                    {
                        isATMC = true;
                    }
                    if (tmi.Text.Equals(dockContent.Text))
                    {
                        dockContent.Select();
                        break;
                    }
                }
                if (tmi.Text == "NDCServer_2" && !isAlreadyNDC_2)
                {
                    Form_NDCServer_2 form_NDCServer2 = new Form_NDCServer_2();
                    form_NDCServer2.Show(this.dockPanel1, DockState.Document);
                }
                else if (tmi.Text == "NDCServer" && !isAlreadyNDC_1)
                {
                    Form_NDCServer form_NDCServer1 = new Form_NDCServer();
                    form_NDCServer1.Show(this.dockPanel1, DockState.Document);
                }
                else if (tmi.Text == "DDCServer" && !isAlreadyDDC_1)
                {
                    Form_DDCServer form_DDCServer1 = new Form_DDCServer();
                    form_DDCServer1.Show(this.dockPanel1, DockState.Document);
                }
                else if (tmi.Text == "DDCServer_2" && !isAlreadyDDC_2)
                {
                    MessageBox.Show("Comming Soon...");
                }
                else if (tmi.Text == "VirtualDualHost" && !isAlareadyDualHost)
                {
                    Form_DualHost form_DualHost = new Form_DualHost();
                    form_DualHost.Show(this.dockPanel1, DockState.Document);
                }
                else if (tmi.Text == "ATMC" && !isATMC)
                {
                    form_managerMentMain.Show(this.dockPanel1, DockState.Document);
                }
            }
            break;

            case "SuperParse":
            {
                Form_Pars form_Pars = new Form_Pars();
                form_Pars.Show();
            }
            break;

            case "ScreenParse":
            {
                Form_ScreenParse form_screenPars = new Form_ScreenParse();
                form_screenPars.Show();
            }
            break;

            case "eCAT":
            {
                From_Seeting_eCATPath form_eCAT = new From_Seeting_eCATPath();
                form_eCAT.Show();
            }
            break;

            case "KilleCAT":
            {
                KilleCATFunc();
            }
            break;

            case "StarteCAT":
            {
                StarteCATFunc();
            }
            break;

            case "eCATConfigTool":
            {
                System.Threading.Thread eCATToolThread = new System.Threading.Thread(eCATConfigToolFunc);
                eCATToolThread.IsBackground = true;
                eCATToolThread.Start();
                //eCATConfigToolFunc();
            }
            break;

            case "Open-eCAT":
            {
                //打开eCAT路径
                XDCUnity.OpenPath(XDCUnity.eCATPath);
            }
            break;

            case "Open-XDCHost":
            {
                //打开当前主机路径
                XDCUnity.OpenPath(Environment.CurrentDirectory);
            }
            break;

            case "Open-TrueBack":
            {
                //打开当前主机路径
                CheckTrueBackPath();
                string truebackPath = XDCUnity.TrueBackPath;
                truebackPath = truebackPath.Substring(0, truebackPath.LastIndexOf('\\'));
                XDCUnity.OpenPath(truebackPath);
            }
            break;

            case "ErrorCode":
            {
                Form_ErrorCodeSearch form_errorcode = new Form_ErrorCodeSearch();
                form_errorcode.Show();
            }
            break;

            case "InteractiveBuffer":
            {
                new Form_GetInteractiveMsgTextToShow("").Show();
            }
            break;

            case "About":
            {
                new Form_About().ShowDialog();
            }
            break;

            case "ImportLogsToAutoReply":
            {
                new Form_ImportLogs().Show();
            }
            break;

            case "Exit":
            {
                this.Close();
            }
            break;

            case "C09":
            {
                new Form_C09().Show();
            }
            break;

            default:
                break;
            }
        }
        private void From_Seeting_eCATPath_Load(object sender, EventArgs e)
        {
            //1.当前路径,不知为何,在XP上,如果在当前窗体选择了文件后,使用system.Enviroment获取路径会有差异。所以用这个方法
            //由一个A进程启动B进程,在B进程中使用system.Enviroment获取路径会得到A进程的当前路径。
            string processName = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;

            currentProcessPath = processName.Substring(0, processName.LastIndexOf('\\'));

            //2.获取eCAT路径列表
            string resultXML_eCAT = XMLHelper.instance.XMLFiles["BaseConfig"].GetXmlAttributeValue("BaseConfig.Settings.eCATPath.[*].{*}");

            if (!string.IsNullOrEmpty(resultXML_eCAT))
            {
                List <string> eCATPathList = XDCUnity.GetXmlValueList(resultXML_eCAT);
                cmb_eCAT.DataSource = eCATPathList;
            }
            string resultXML_TrueBack = XMLHelper.instance.XMLFiles["BaseConfig"].GetXmlAttributeValue("BaseConfig.Settings.TrueBackPath.[*].{*}");

            if (!string.IsNullOrEmpty(resultXML_TrueBack))
            {
                List <string> trueBackPathList = XDCUnity.GetXmlValueList(resultXML_TrueBack);
                cmb_Trueback.DataSource = trueBackPathList;
            }

            //3.获取当前默认的eCAT路径
            XmlDocument doc          = XMLHelper.instance.XMLFiles["BaseConfig"].XmlDoc;
            XmlNode     eCATnode     = doc.SelectSingleNode("BaseConfig/Settings/eCATPath");
            XmlNode     trueBacknode = doc.SelectSingleNode("BaseConfig/Settings/TrueBackPath");

            //默认选中eCAT
            string currenteCATPath = eCATnode.Attributes["value"].InnerText;

            if (cmb_eCAT.Items.Contains(currenteCATPath))
            {
                cmb_eCAT.Text = currenteCATPath;
            }

            //默认选中TrueBack
            string currentTruebackPath = trueBacknode.Attributes["value"].InnerText;

            if (cmb_Trueback.Items.Contains(currentTruebackPath))
            {
                cmb_Trueback.Text = currentTruebackPath;
            }

            //编码 add by frde 20160628
            XmlNode formatCode  = doc.SelectSingleNode("BaseConfig/Settings/FormatCode");
            string  currentCode = formatCode.Attributes["value"].InnerText;

            switch (currentCode.ToUpper())
            {
            case "ASCII":
            {
                rbt_ASCII.Checked = true;
            }
            break;

            case "EBCD":
            {
                rbt_EBCD.Checked = true;
            }
            break;

            default:
                break;
            }

            XDCUnity.CurrentFormatCode = currentCode;
            currentFormatCodenode      = formatCode;
        }
Пример #27
0
        /// <summary>
        /// 获取xml节点列表
        /// </summary>
        /// <returns></returns>
        public static List <TemplateView> GetXmlConfig(XDCMessage CurrentMessage)
        {
            string[] tempArrary = CurrentMessage.MsgASCIIStringFields;
            XmlNode  root       = null;
            string   attrID     = "";
            //1NDC|2DDC
            string attrProtocolType = "1";
            //1State
            //2Screen
            //3Fit
            //4Message
            string  attrDataType = "4";
            XmlNode cur          = null;
            string  commandCode  = "";

            string MessageIdentifier = "";
            int    sdIndex           = 3;

            root = XMLHelper.instance.XMLFiles["ProtocolTemplate"].XmlDoc.SelectSingleNode("ProtocolTemplate");
            switch (CurrentMessage.MsgType)
            {
            case MessageType.DataCommand:
            {
                #region 3x_DataCommand

                commandCode       = tempArrary[3].Substring(0, 1);
                MessageIdentifier = commandCode;
                attrID            = "3FSFSFS" + commandCode;
                cur = XDCUnity.GetNodeDetail(root, attrID, attrProtocolType, attrDataType);
                if (null == cur)
                {
                    //通常查询xml文件中ID=1的配置
                    attrID = tempArrary[0].Substring(0, 1);
                    cur    = XDCUnity.GetNodeDetail(root, attrID, attrProtocolType, attrDataType);
                }
                #endregion
            }
            break;

            case MessageType.TerminalCommand:
            {
                #region 1x_TerminalCommand

                commandCode = tempArrary[3].Substring(0, 1);
                //TerminalCommand消息中,MessageIdentifier的值等于commandCode,因为
                //TerminalCommand消息LUNO号后只有一个FS
                MessageIdentifier = commandCode;
                attrID            = "1FSFSFS" + commandCode;
                cur = XDCUnity.GetNodeDetail(root, attrID, attrProtocolType, attrDataType);
                if (null == cur)
                {
                    //通常查询xml文件中ID=1的配置
                    attrID = tempArrary[0].Substring(0, 1);
                    cur    = XDCUnity.GetNodeDetail(root, attrID, attrProtocolType, attrDataType);
                }
                #endregion
            }
            break;

            case MessageType.SolicitedMessage:
            {
                #region 22||23_SolicitedMessage
                attrID = tempArrary[0] + "FSFSFS";
                int fsCount = 3;
                try
                {
                    commandCode = tempArrary[sdIndex].Substring(0, 1);
                }
                catch
                {
                    commandCode = "";
                }
                if (tempArrary.Length > sdIndex + 1)
                {
                    MessageIdentifier = tempArrary[sdIndex + 1].Substring(0, 1);
                }
                attrID += commandCode;
                string tempXMLid = "";
                string miString  = "";
                if (commandCode == "8" ||
                    commandCode == "C" ||
                    commandCode == "F")
                {
                    miString = "FS" + MessageIdentifier;
                    fsCount++;
                }

                int maxFsCountRear = tempArrary.Length - fsCount - 1;
                //最多的FS,并逐个递减
                while (maxFsCountRear > -1)
                {
                    tempXMLid = attrID + miString + XDCUnity.GetFS(maxFsCountRear);
                    cur       = XDCUnity.GetNodeDetail(root, tempXMLid, attrProtocolType, attrDataType);
                    if (null != cur)
                    {
                        break;
                    }
                    maxFsCountRear--;
                }
                //如果还未空,去掉MessageIdentifier
                if (null == cur)
                {
                    tempXMLid = attrID;
                    cur       = XDCUnity.GetNodeDetail(root, tempXMLid, attrProtocolType, attrDataType);
                    if (null == cur)
                    {
                        tempXMLid = tempArrary[0];
                        cur       = XDCUnity.GetNodeDetail(root, tempXMLid, attrProtocolType, attrDataType);
                    }
                }
                #endregion
            }
            break;

            case MessageType.UnSolicitedMessage:
            {
                #region 12||11_UnSolicitedMessage
                try
                {
                    commandCode = tempArrary[3].Substring(0, 1);
                }
                catch
                {
                    commandCode = "";
                }
                attrID = tempArrary[0] + "FSFSFS" + commandCode;
                if (tempArrary[0].Equals("11"))
                {
                    try
                    {
                        MessageIdentifier = tempArrary[13].Substring(0, 1);
                    }
                    catch
                    {
                        MessageIdentifier = "";
                    }
                }

                cur = XDCUnity.GetNodeDetail(root, attrID, attrProtocolType, attrDataType);
                if (null == cur)
                {
                    attrID = tempArrary[0];
                    cur    = XDCUnity.GetNodeDetail(root, attrID, attrProtocolType, attrDataType);
                }
                #endregion
            }
            break;

            case MessageType.TransactionReplyCommand:
            {
                #region 4_TransactionReplyCommand

                attrID = "4";
                cur    = XDCUnity.GetNodeDetail(root, attrID, attrProtocolType, attrDataType);

                #endregion
            }
            break;

            case MessageType.UploadEJMessage:
            {
                #region 6x_UploadEJMessage
                try
                {
                    commandCode       = tempArrary[3].Substring(0, 1);
                    MessageIdentifier = commandCode;
                }
                catch
                {
                    commandCode       = "";
                    MessageIdentifier = commandCode;
                }
                attrID = tempArrary[0].Substring(0, tempArrary[0].Length);
                cur    = XDCUnity.GetNodeDetail(root, attrID, attrProtocolType, attrDataType);
                if (null == cur)
                {
                    attrID = tempArrary[0].Substring(0, 1);
                    cur    = XDCUnity.GetNodeDetail(root, attrID, attrProtocolType, attrDataType);
                }
                #endregion
            }
            break;

            case MessageType.ExitToHostMessages:
            {
            }
            break;

            case MessageType.HostToExitMessages:
            {
                #region 7_HostToExitMessages

                attrID = tempArrary[0].Substring(0, 1);
                cur    = XDCUnity.GetNodeDetail(root, attrID, attrProtocolType, attrDataType);

                #endregion
            }
            break;

            case MessageType.Unknow:
                break;

            default:
                break;
            }
            if (null == cur)
            {
                return(null);
            }
            bool alreadyFS_X           = true;;
            List <TemplateView> TvList = new List <TemplateView>();
            foreach (XmlNode item in cur.ChildNodes)
            {
                TemplateView tv        = new TemplateView();
                XmlAttribute fieldName = item.Attributes["Name"];
                XmlAttribute fieldSize = item.Attributes["Size"];

                if (fieldName != null)
                {
                    tv.FieldName = fieldName.Value;
                }
                if ((tv.FieldName.StartsWith("FS") && tv.FieldName.Length > 2) ||
                    (tv.FieldName.StartsWith("GS") && tv.FieldName.Length > 2))
                {
                    if (tv.FieldName.Contains('|'))
                    {
                        bool     isFoundInnerFS = false;
                        string[] fsSpliterArray = tv.FieldName.Replace("FS", "").Split('|');
                        foreach (string fsSpliterStr in fsSpliterArray)
                        {
                            if (MessageIdentifier == fsSpliterStr)
                            {
                                tv.FieldName   = "FS";
                                isFoundInnerFS = true;
                                alreadyFS_X    = true;
                                break;
                            }
                            else
                            {
                                isFoundInnerFS = false;
                            }
                        }
                        if (!isFoundInnerFS)
                        {
                            continue;
                        }
                    }
                    else if (tv.FieldName.Equals("FS" + "*"))
                    {
                        //找到FS*
                        tv.FieldName = "FS*";
                        alreadyFS_X  = true;
                    }
                    //已FS开头,但是不等於FS/GS的需要越过两行
                    else if (!tv.FieldName.Equals("FS" + MessageIdentifier) &&
                             !tv.FieldName.Equals("GS" + MessageIdentifier))
                    {
                        alreadyFS_X = false;
                        continue;
                    }
                    else
                    {
                        tv.FieldName = tv.FieldName.Substring(0, 2);
                        alreadyFS_X  = true;
                    }
                }
                else if (tv.FieldName.Equals("FS"))
                {
                    alreadyFS_X = true;
                }
                if (!alreadyFS_X)
                {
                    continue;
                }

                if (fieldSize != null)
                {
                    int  fSize;
                    bool isNumeric = int.TryParse(fieldSize.Value, out fSize);
                    if (isNumeric)
                    {
                        tv.FieldSize = fSize;
                    }
                    else
                    {
                        //非数字的情况,如*
                        tv.FieldSize = -1;
                    }
                }
                if (item.HasChildNodes)
                {
                    Dictionary <string, string> dic = new Dictionary <string, string>();
                    foreach (XmlNode valueItem in item.ChildNodes)
                    {
                        XmlAttribute attrComment   = valueItem.Attributes["Comment"];
                        XmlAttribute attrOperation = valueItem.Attributes["Operation"];
                        if (attrOperation != null)
                        {
                            //进行&运算
                            if (attrOperation.Value.StartsWith("&"))
                            {
                                //&运算
                                string ampValue = attrOperation.Value.Replace("&", "");
                                dic.Add(valueItem.InnerText + "&amp;" + ampValue, attrComment.Value);
                            }
                        }
                        else if (null != attrComment &&
                                 !dic.ContainsKey(valueItem.InnerText))
                        {
                            dic.Add(valueItem.InnerText, attrComment.Value);
                        }
                        if (valueItem.InnerText != "*")
                        {
                            tv.FieldSize = valueItem.InnerText.Length > tv.FieldSize ? valueItem.InnerText.Length : tv.FieldSize;
                        }
                    }
                    tv.FieldValue = dic;
                }
                TvList.Add(tv);
            }


            return(TvList);
        }
Пример #28
0
        public List <ParsRowView> GetView(string parsText)
        {
            List <ParsRowView> result = new List <ParsRowView>();
            //NDC OR DDC
            string attrProtocolType = "0";
            //State
            string attrDataType = "3";

            XmlNode cur = XDCUnity.GetNodeDetail(XDCUnity.Root, attrProtocolType, attrDataType);

            if (cur == null)
            {
                //NDC OR DDC
                attrProtocolType = "0";
                cur = XDCUnity.GetNodeDetail(XDCUnity.Root, attrProtocolType, attrDataType);
            }
            if (cur != null)
            {
                //each 3 bit for one group,this values will be used as the base value to calculate for hex.
                List <string> parsTextInList = new List <string>();
                string        SingFieldText  = string.Empty;
                for (int i = 0; i < parsText.Length; i++)
                {
                    SingFieldText += parsText[i];
                    if ((i + 1) % 3 == 0)
                    {
                        parsTextInList.Add(SingFieldText);
                        SingFieldText = "";
                    }
                }

                string tempValue         = "";
                string tempValueBeforHex = "";
                int    listIndex         = 0;
                foreach (XmlNode item in cur.ChildNodes)
                {
                    TemplateView tv        = new TemplateView();
                    XmlAttribute fieldName = item.Attributes["Name"];
                    XmlAttribute fieldSize = item.Attributes["Size"];
                    ParsRowView  prv       = new ParsRowView();
                    tempValue         = "";
                    tempValueBeforHex = "";
                    int size;
                    int.TryParse(fieldSize.Value, out size);
                    int realSize = size / 3;// 3 bit to calculate for hex value--frde 20151117

                    string tempComment = "";
                    for (int i = 0; i < realSize; i++)
                    {
                        try
                        {
                            //可能缺少数据的情况
                            tempValue         += int.Parse(parsTextInList[listIndex]).ToString("X2");
                            tempValueBeforHex += parsTextInList[listIndex];
                        }
                        catch
                        {
                            tempComment = "Invalid Length";
                        }
                        finally
                        {
                            listIndex++;
                        }
                    }

                    if (string.IsNullOrEmpty(tempComment) && item.HasChildNodes)
                    {
                        foreach (XmlNode commentItem in item.ChildNodes)
                        {
                            string       commentValue       = commentItem.InnerText;
                            string       commentText        = commentItem.Attributes["Comment"].Value;
                            XmlAttribute commentIsOperation = commentItem.Attributes["Operation"];
                            if (null != commentIsOperation)
                            {
                                if (commentIsOperation.Value.StartsWith("&"))
                                {
                                    //&运算
                                    string ampValue  = commentIsOperation.Value.Replace("&", "");
                                    int    ampResult = int.Parse(tempValueBeforHex) & int.Parse(ampValue);
                                    //string hexValue = ampResult.ToString("X2");
                                    if (ampResult == int.Parse(commentValue))
                                    {
                                        tempComment = commentText;
                                        break;
                                    }
                                }
                            }
                            else if (tempValue.Equals(commentValue.Trim()))
                            {
                                tempComment = commentText;
                            }
                        }
                    }
                    result.Add(new ParsRowView(fieldName.Value.ToString(), tempValue, tempComment));
                }
                return(result);
            }
            else
            {
                return(null);
            }
        }
Пример #29
0
        /// <summary>
        /// 获取xml节点列表
        /// </summary>
        /// <returns></returns>
        public static void GetXmlConfig(XDCMessage CurrentMessage)
        {
            string[] tempArrary = CurrentMessage.MsgASCIIStringFields;
            XmlNode  root       = null;
            string   attrID     = "";
            //1NDC|2DDC
            string attrProtocolType = "2";
            //1State
            //2Screen
            //3Fit
            //4Message
            string  attrDataType = "4";
            XmlNode cur          = null;
            string  commandCode  = "";

            string MessageIdentifier = "";
            int    sdIndex           = 3;

            root = XMLHelper.instance.XMLFiles["ProtocolTemplate"].XmlDoc.SelectSingleNode("ProtocolTemplate");
            switch (CurrentMessage.MsgType)
            {
            case MessageType.DataCommand:
            {
                #region 3x_DataCommand

                //DDC的状态、屏幕、FIT等,有 tempArrary[3]做为commandCode
                commandCode       = tempArrary[3].Substring(0, 1);
                MessageIdentifier = tempArrary[3].Substring(1, 1);
                attrID            = "3FSFSFS" + commandCode + MessageIdentifier;
                cur = XDCUnity.GetNodeDetail(root, attrID, attrProtocolType, attrDataType);
                if (null == cur)
                {
                    attrID = "3FSFSFS" + commandCode;
                    cur    = XDCUnity.GetNodeDetail(root, attrID, attrProtocolType, attrDataType);
                    if (null == cur)
                    //通常查询xml文件中ID=1的配置
                    {
                        attrID = tempArrary[0].Substring(0, 1);
                        cur    = XDCUnity.GetNodeDetail(root, attrID, attrProtocolType, attrDataType);
                    }
                }
                #endregion
            }
            break;

            case MessageType.TerminalCommand:
            {
                #region 1x_TerminalCommand

                commandCode = tempArrary[3].Substring(0, 1);
                //TerminalCommand消息中,MessageIdentifier的值等于commandCode,因为
                //TerminalCommand消息LUNO号后只有一个FS
                MessageIdentifier = commandCode;
                attrID            = "1FSFSFS" + commandCode;
                cur = XDCUnity.GetNodeDetail(root, attrID, attrProtocolType, attrDataType);
                if (null == cur)
                {
                    //通常查询xml文件中ID=1的配置
                    attrID = tempArrary[0].Substring(0, 1);
                    cur    = XDCUnity.GetNodeDetail(root, attrID, attrProtocolType, attrDataType);
                }
                #endregion
            }
            break;

            case MessageType.SolicitedMessage:
            {
                #region 22||23_SolicitedMessage
                attrID = tempArrary[0] + "FSFSFS";
                int fsCount = 3;
                try
                {
                    commandCode = tempArrary[sdIndex].Substring(0, 1);
                }
                catch
                {
                    commandCode = "";
                }
                if (tempArrary.Length > sdIndex + 1)
                {
                    MessageIdentifier = tempArrary[sdIndex + 1].Substring(0, 1);
                }
                attrID += commandCode;
                string tempXMLid = "";
                string miString  = "";
                if (commandCode == "8" ||
                    commandCode == "C" ||
                    commandCode == "F")
                {
                    miString = "FS" + MessageIdentifier;
                    fsCount++;
                }

                int maxFsCountRear = tempArrary.Length - fsCount - 1;
                //最多的FS,并逐个递减
                while (maxFsCountRear > -1)
                {
                    tempXMLid = attrID + miString + XDCUnity.GetFS(maxFsCountRear);
                    cur       = XDCUnity.GetNodeDetail(root, tempXMLid, attrProtocolType, attrDataType);
                    if (null != cur)
                    {
                        break;
                    }
                    maxFsCountRear--;
                }
                //如果还未空,去掉MessageIdentifier
                if (null == cur)
                {
                    tempXMLid = attrID;
                    cur       = XDCUnity.GetNodeDetail(root, tempXMLid, attrProtocolType, attrDataType);
                    if (null == cur)
                    {
                        tempXMLid = tempArrary[0];
                        cur       = XDCUnity.GetNodeDetail(root, tempXMLid, attrProtocolType, attrDataType);
                    }
                }
                #endregion
            }
            break;

            case MessageType.UnSolicitedMessage:
            {
                #region 12||11_UnSolicitedMessage
                try
                {
                    commandCode = tempArrary[3].Substring(0, 1);
                }
                catch
                {
                    commandCode = "";
                }
                MessageIdentifier = commandCode;
                attrID            = tempArrary[0] + "FSFSFS" + commandCode;
                if (tempArrary[0].Equals("11"))
                {
                    try
                    {
                        MessageIdentifier = tempArrary[13].Substring(0, 1);
                    }
                    catch
                    {
                        MessageIdentifier = "";
                    }
                }

                cur = XDCUnity.GetNodeDetail(root, attrID, attrProtocolType, attrDataType);
                if (null == cur)
                {
                    attrID = tempArrary[0];
                    cur    = XDCUnity.GetNodeDetail(root, attrID, attrProtocolType, attrDataType);
                }
                #endregion
            }
            break;

            case MessageType.TransactionReplyCommand:
            {
                #region 4_TransactionReplyCommand
                //扩张功能命令:‘
                attrID = "4";
                if (CurrentMessage.MsgASCIIString.Contains(XDCSplictorChar.FS + "'"))
                {
                    MessageIdentifier = "'";
                }
                cur = XDCUnity.GetNodeDetail(root, attrID, attrProtocolType, attrDataType);

                #endregion
            }
            break;

            case MessageType.UploadEJMessage:
            {
                #region 6x_UploadEJMessage
                try
                {
                    commandCode       = tempArrary[3].Substring(0, 1);
                    MessageIdentifier = commandCode;
                }
                catch
                {
                    commandCode       = "";
                    MessageIdentifier = commandCode;
                }
                attrID = tempArrary[0].Substring(0, tempArrary[0].Length);
                cur    = XDCUnity.GetNodeDetail(root, attrID, attrProtocolType, attrDataType);
                if (null == cur)
                {
                    attrID = tempArrary[0].Substring(0, 1);
                    cur    = XDCUnity.GetNodeDetail(root, attrID, attrProtocolType, attrDataType);
                }
                #endregion
            }
            break;

            case MessageType.ExitToHostMessages:
            {
            }
            break;

            case MessageType.HostToExitMessages:
            {
                #region 7_HostToExitMessages

                attrID = tempArrary[0].Substring(0, 1);
                cur    = XDCUnity.GetNodeDetail(root, attrID, attrProtocolType, attrDataType);

                #endregion
            }
            break;

            case MessageType.Unknow:
                break;

            default:
                break;
            }

            CurrentNode = cur;
        }
Пример #30
0
 /// <summary>
 /// 关闭eCAT
 /// </summary>
 private void KilleCATFunc()
 {
     CheckeCATPath();
     XDCUnity.KilleCAT();
 }