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.; }
void ReadVariable(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("More than 1 variable to read."); } else { CDDLBase ddb = new CDDLBase(); if (hartDev.getItembyName((string)paras[0].value, ref ddb)) { if (ddb.GetType() == typeof(CDDLVar)) { CDDLVar vartoread = (CDDLVar)ddb; hCcommandDescriptor pCmdDesc = vartoread.getRdCmdList().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 = vartoread.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("The variable name is not valid."); } } }