Exemplo n.º 1
0
        void DiagnoseDev(parameters paras, out results rets)
        {
            rets = new results();
            result       rst    = new result();
            ThreadUpdate tusend = new ThreadUpdate();

            if (paras.Count != 1)
            {
                rets.response = rspCode.negitive;
                rets.resDesc  = "More than 1 variable to read.";
            }
            else
            {
                CFRAME_PARSE_NODE cFrameParse = new CFRAME_PARSE_NODE();

                if (DPDev.diagDevice(0, ref cFrameParse))
                {
                    //if (hartDev.pCmdDispatch.SendCmd(pCmd, pCmdDesc.transNumb) == Common.SUCCESS)
                    {
                        /*
                         * rets.response = (hartDev.parentform.getCmdRes() as results).response;//getCmdRes
                         * rst.name = (string)paras[0].value;
                         * //rst.rtype = resultDataType.floatpoint;
                         * rst.value = vartoread.GetDispString();
                         * rets.Add(rst);
                         */
                        string slaveState = DPDev.parseSlaveStateByDiag(cFrameParse.aucData, cFrameParse.ucDataLen);
                        rst       = new result();
                        rst.name  = "SlaveState";
                        rst.value = slaveState;
                        rets.Add(rst);

                        string DiagnoseInfo = "";
                        DPDev.parseDiagnosticsInfo(cFrameParse.aucData, cFrameParse.ucDataLen, ref DiagnoseInfo);
                        rst       = new result();
                        rst.name  = "DiagnoseInfo";
                        rst.value = DiagnoseInfo;
                        rets.Add(rst);
                    }
                    //else
                    {
                        rets.response = rspCode.positive;
                        //rets.resDesc = String.Format("The Command {0}, transaction {1} cannot be sent.", pCmdDesc.cmdNumber, pCmdDesc.transNumb);
                    }
                }
                else
                {
                    rets.response = rspCode.negitive;
                    rets.resDesc  = "The Diagnose is failed.";
                }
            }
        }
Exemplo n.º 2
0
        void WriteVariable(parameters paras, out results rets)
        {
            rets = new results();
            result       rst    = new result();
            ThreadUpdate tusend = new ThreadUpdate();

            if (paras.Count != 1)
            {
                rets.response = rspCode.negitive;
                rets.resDesc  = "More than 1 variable to read.";
                saveLogfile(rets.resDesc);
            }
            else
            {
                CDDLBase ddb = new CDDLBase();
                if (hartDev.getItembyName((string)paras[0].value, ref ddb))
                {
                    if (ddb.GetType() == typeof(CDDLVar))
                    {
                        CDDLVar             vartowrite = (CDDLVar)ddb;
                        hCcommandDescriptor pCmdDesc   = vartowrite.getWrCmdList().ElementAt(0);
                        CDDLCmd             pCmd       = hartDev.Cmds.getCmdByNumber(pCmdDesc.cmdNumber);
                        if (hartDev.pCmdDispatch.SendCmd(pCmd, pCmdDesc.transNumb, null, logSw) == Common.SUCCESS)
                        {
                            saveLogfile("Command {0}, transaction {1} sent.", pCmdDesc.cmdNumber, pCmdDesc.transNumb);
                            returncode creply = hartDev.parentform.ReData(null);
                            hartDev.parentform.setThread(tusend);
                            tusend.ucTranNumSent = (byte)pCmdDesc.transNumb;
                            tusend.ucCmdSent     = (byte)pCmdDesc.cmdNumber;
                            hartDev.parentform.procRcvData(creply, pCmdDesc.transNumb, pCmd.getCmdNumber(), pCmd.getOperation());
                            rets.response = (hartDev.parentform.getCmdRes() as results).response;//getCmdRes

                            //rst.name = (string)paras[0].value;
                            //rst.rtype = resultDataType.floatpoint;
                            //rst.value = vartowrite.GetDispString();

                            rets.Add(rst);
                        }
                        else
                        {
                            rets.response = rspCode.negitive;
                            rets.resDesc  = String.Format("The Command {0}, transaction {1} cannot be sent.", pCmdDesc.cmdNumber, pCmdDesc.transNumb);
                            saveLogfile(rets.resDesc);
                        }
                    }
                    else
                    {
                        rets.response = rspCode.negitive;
                        rets.resDesc  = "The item is not a variable.";
                        saveLogfile(rets.resDesc);
                    }
                }
                else
                {
                    rets.response = rspCode.negitive;
                    rets.resDesc  = "The variable name is not valid.";
                    saveLogfile(rets.resDesc);
                }
            }
        }
Exemplo n.º 3
0
        void GetDeviceInfo(parameters paras, out results rets)
        {
            rets = new results();
            result rst = new result();

            if (paras.Count != 0)
            {
                rets.response = rspCode.negitive;
                rets.resDesc  = "No paramater is allowed for this function.";
                saveLogfile(rets.resDesc);
            }
            else
            {
                DeviceDetails dev     = new DeviceDetails();
                List <string> devInfo = dev.getDevDetails(hartDev);

                if (devInfo.Count != 4)
                {
                    rets.response = rspCode.negitive;
                    rets.resDesc  = "No paramater is allowed for this function.";
                    saveLogfile(rets.resDesc);
                }
                else
                {
                    saveLogfile("Getting device info.");
                    rst       = new result();
                    rst.name  = "manuID";
                    rst.value = devInfo[0];
                    rets.Add(rst);
                    rst       = new result();
                    rst.name  = "devType";
                    rst.value = devInfo[1];
                    rets.Add(rst);
                    rst       = new result();
                    rst.name  = "devRev";
                    rst.value = devInfo[2];
                    rets.Add(rst);
                    rst       = new result();
                    rst.name  = "ddRev";
                    rst.value = devInfo[3];
                    rets.Add(rst);
                    rets.response = rspCode.positive;
                }
            }
        }
Exemplo n.º 4
0
        void GetGSDInfo(parameters paras, out results rets)
        {
            DPDev.parseGSD(0, logSw);
            //将信息写入到文本框中
            rets = new results();
            result rst = new result();

            rst.name  = "Vendor_Name";
            rst.value = DPDev.pGSD.cGsdFileInfoEntity.strVendor_Name;
            rets.Add(rst);
            rst       = new result();
            rst.name  = "Model_Name";
            rst.value = DPDev.pGSD.cGsdFileInfoEntity.strModel_Name;
            rets.Add(rst);
            rst       = new result();
            rst.name  = "Ident_Number";
            rst.value = (int)DPDev.pGSD.cGsdFileInfoEntity.uiIdent_Number;
            rets.Add(rst);
            rets.response = rspCode.positive;
        }
Exemplo n.º 5
0
        void GetDDInfo(parameters paras, out results rets)
        {
            saveLogfile("Getting Varible list from DD file");
            rets = new results();
            result rst = new result();

            rst.name  = "NumOfVars";
            rst.value = hartDev.Vars.Count;
            rets.Add(rst);
            saveLogfile("Getting command list from DD file");
            rst       = new result();
            rst.name  = "NumOfCmds";
            rst.value = hartDev.Cmds.Count;
            rets.Add(rst);
            saveLogfile("Getting collection list from DD file");
            rst       = new result();
            rst.name  = "NumOfColletions";
            rst.value = hartDev.Collections.Count;
            rets.Add(rst);
            rets.response = rspCode.positive;
        }