Пример #1
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);
                }
            }
        }
Пример #2
0
        public List <string> getDevDetails(HARTDevice dev)
        {
            List <string> devInfo   = new List <string>();
            CDDLBase      pItemBase = null;

            if (dev.getItembyID(DEVICE_DISTRIBUTOR, ref pItemBase))
            {
                if (pItemBase.eType == nitype.nVar)
                {
                    CDDLVar devdis = pItemBase as CDDLVar;
                    devdis.getDispValue().SetValue((int)dev.ddbDeviceID.wManufacturer, valueType_t.isIntConst);
                    m_strDistributor = devdis.GetDispString();
                }
            }

            if (dev.getItembyID(DEVICE_DEVICE_TYPE, ref pItemBase))
            {
                if (pItemBase.eType == nitype.nVar)
                {
                    CDDLVar devtype = pItemBase as CDDLVar;
                    m_strType = devtype.GetDispString();
                }
            }

            m_strDDRevision = dev.parentform.strDDRevision;
            m_strRevision   = dev.parentform.strDeviceRevision;
            devInfo.Add(m_strDistributor);
            devInfo.Add(m_strType);
            devInfo.Add(m_strDDRevision);
            devInfo.Add(m_strRevision);
            return(devInfo);
            //strDDfile = dev.;
        }
Пример #3
0
 public void updateVarRelation()
 {
     foreach (uint wid in watchVarList)
     {
         CDDLVar wVar = null;
         if (pDev.getVarbyID(wid, ref wVar))
         {
             foreach (uint uid in updateVarList)
             {
                 wVar.relationVarList.Add(uid);
             }
         }
     }
 }
Пример #4
0
        public CDDLVar getVarPtrBySymNumber(uint symNum)
        {
            CDDLBase pItem = new CDDLBase();
            CDDLVar  pVar  = null;

            if (symNum != 0)
            {
                if (pDev.getItembyID(symNum, ref pItem))
                {
                    if (pItem.IsVariable())
                    {
                        pVar = (CDDLVar)pItem;
                    }
                    else
                    {
                        //DEBUGLOG(CLOG_LOG | CERR_LOG, "%s (0x%04x) Expected to be a variable.(dbg-only msg)\n", pItem.getName().c_str(), pItem.getID());
                    }
                }
            }
            return(pVar);// null on error
        }
Пример #5
0
        public void getDevCommStatus(HARTDevice dev)
        {
            CDDLBase pItemBase = null;

            if (dev.getItembyID(DeviceDetails.DEVICE_COMM_STATUS, ref pItemBase))
            {
                if (pItemBase.eType == nitype.nVar)
                {
                    CDDLVar comstatus = pItemBase as CDDLVar;
                    nCommStatusValue = comstatus.getDispValue().GetInt();
                }
            }

            if (dev.getItembyID(DeviceDetails.DEVICE_COMM48_STATUS, ref pItemBase))
            {
                if (pItemBase.eType == nitype.nVar)
                {
                    CDDLVar devstatus = pItemBase as CDDLVar;
                    nDevStatusValue = devstatus.getDispValue().GetInt();
                }
            }
        }
Пример #6
0
        public int updateVarUnit()
        {
            int rc = Common.SUCCESS;
            //cmdOperationType_t o = cmdOperationType_t.cmdOpNone,
            //O = cmdOperationType_t.cmdOpNone;
            //listOptrs2dataItemLists_t::iterator iP2DIL;
            CDDLBase pThisVarItem = new CDDLBase();

            foreach (uint varid in VarIdList)
            {
                if (pDev.getItembyID(varid, ref pThisVarItem))
                {
                    CDDLVar var = (CDDLVar)pThisVarItem;
                    //var.unitrelationID = getID();
                    //var.unitlist = enumlist;
                    //var.unitidlist = enumIDlist;
                    var.unitrelationID = unitVarId;
                    //var.setUnitFromList();
                }
            }

            return(rc);
        }