'***Script: pbGetXYofAlarmingDevice '*** Created By: Michael R. Miller '*** Description: Return the xy coordinate of the structure associated to an equipment feature '*** Uses Globals: _SQLCon '*** Creates Globals: none '*** Calls: pbWriteAlarmLog '*** Called By: pbAddAlarm '*** Input Parameters: theTransID, theX, theY, theNodeName, theEquipName, theNodeStatus, retCode '*** History: none '*** Assign parameters from list to variables theParmList = Self For each parm in theParmList theTransID = theParmList.Get(0) theX = theParmList.Get(1) theY = theParmList.Get(2) theNodeName = theParmList.Get(3) theEquipName = theParmList.Get(4) theNodeStatus = theParmList.Get(5) retCode = theParmList.Get(6) end '*** Temporary declaration of globals for return parameter passing bug _theX = 0 _theY = 0 _theNodeName = "" _theEquipName = "" _theNodeStatus = "" _getXYRetCode = false '*** Select DB-Able EQUIPMENT record associated to the Transponder ID from LANguard theQuery = "Select STRUCTURE_ID,DESIGN_NODE,NAME From EQUIPMENT Where EQUIPMENT.TRANS_ID = " + "'" + theTransID + "'" theEquipVTab = VTab.MakeSQL(_theSQLCon,theQuery) '*** Test for successful DB-Able query matchCount = theEquipVTab.GetNumRecords if (matchCount = 0) then if (_alarmLogging = True) then theScript = "pbGetXYofAlarmingDevice" theStatus = "not ok" theMessage = "Transponder ID not found in DB-Able" RetCode = false theParmList = {theScript,theStatus,theMessage,retCode} av.run("pbWriteAlarmLog", theParmList) end theParmList = {"","","","","","",False} return(theParmList) else if (matchCount > 1) then theScript = "pbGetXYofAlarmingDevice" theStatus = "not ok" theMessage = "Transponder ID not unique in DB-Able" RetCode = false theParmList = {theScript,theStatus,theMessage,retCode} av.run("pbWriteAlarmLog", theParmList) theParmList = {"","","","","","",False} return(theParmList) end end '*** Get the node name from the equipment table theFieldName = theEquipVTab.FindField("DESIGN_NODE") theNodeName = theEquipVTab.ReturnValueString(theFieldName,0) '*** Search for selected node in node status table theNodeStatTab = _project.FindDoc("NetAnalyzer Node Attributes") theNodeStatVTab = theNodeStatTab.GetVTab theBitMap = theNodeStatVTab.GetSelection theBitMap.ClearAll theExpr = "([Node_Name] = """ + theNodeName + """)" theNodeStatVTab.Query(theExpr,theBitmap,#VTAB_SELTYPE_NEW) theNodeStatVTab.UpdateSelection '*** If the node is not found then return without adding the alarm theCount = theBitmap.Count if (theCount = 0) then theBitMap.ClearAll theScript = "pbGetXYofAlarmingDevice" theStatus = "not ok" theMessage = "Node ID:" + theNodeName + " not found in Node Attribute Table" RetCode = false theParmList = {theScript,theStatus,theMessage,retCode} av.run("pbWriteAlarmLog", theParmList) theParmList = {"","","","","","",False} return(theParmList) end '*** If the status = "I" (for "Inactive") then exit without adding the alarm For each rec in theBitMap theField = theNodeStatVTab.FindField("Status") theNodeStatus = theNodeStatVTab.ReturnValue(theField,rec) _theNodeStatus = theNodeStatus if (theNodeStatus = "I") then if (_alarmLogging = True) then theScript = "pbGetXYofAlarmingDevice" theStatus = "ok" theMessage = "Alarm processing not enabled for this node: " + theNodeName retCode = false theParmList = {theScript,theStatus,theMessage,retCode} av.run("pbWriteAlarmLog", theParmList) end theBitMap.ClearAll theParmList = {"","","","","","",True} return(theParmList) end end theBitMap.ClearAll '*** Get the equipment name from the equipment table theFieldName = theEquipVTab.FindField("NAME") theEquipName = theEquipVTab.ReturnValueString(theFieldName,0) '*** Get the Structure ID value from the selected DB-Able record theFieldName = theEquipVTab.FindField("STRUCTURE_ID") theStructID = theEquipVTab.ReturnValueString(theFieldName,0) '*** Select DB-Able STRUCTURE record associated to the selected EQUIPMENT record theQuery = "Select STRUCT_X_GEO,STRUCT_Y_GEO From STRUCTURE Where STRUCTURE_ID = " + theStructID theStructVTab = VTab.MakeSQL(_theSQLCon,theQuery) '*** Test for successful DB-Able query matchCount = theStructVTab.GetNumRecords if (matchCount = 0) then theScript = "pbGetXYofAlarmingDevice" theStatus = "not ok" theMessage = "Structure ID not found in DB-Able" RetCode = false theParmList = {theScript,theStatus,theMessage,retCode} av.run("pbWriteAlarmLog", theParmList) theParmList = {"","","","","","",False} return(theParmList) else if (matchCount > 1) then theScript = "pbGetXYofAlarmingDevice" theStatus = "not ok" theMessage = "Structure ID not unique in DB-Able" RetCode = false theParmList = {theScript,theStatus,theMessage,retCode} av.run("pbWriteAlarmLog", theParmList) theParmList = {"","","","","","",False} return(theParmList) end end '*** Get the x & y coordinates from the selected STRUCTURE record theFieldName = theStructVTab.FindField("STRUCT_X_GEO") theXCoord = theStructVTab.ReturnValueString(theFieldName,0) theFieldName = theStructVTab.FindField("STRUCT_Y_GEO") theYCoord = theStructVTab.ReturnValueString(theFieldName,0) '*** Shift the x,y coordinates from NAD27 to NAD83 theXCoord = theXCoord.Right(7) '*** Strip off leading digit (zone code) theXCoordNum = theXCoord.AsNumber theYCoordNum = theYCoord.AsNumber if (_region = "ba") then theX = theXCoordNum + 4561375 '*** Add x offset theY = theYCoordNum + 1640410 '*** Add y offset elseif (_region = "sd") then theX = theXCoordNum + 4561375 '*** Add x offset theY = theYCoordNum + 1640410 '*** Add y offset else MsgBox.Error("Somebody screwed up the region code in the startup file!!!","") end '*** Write log file message if (_alarmLogging = true) then theScript = "pbGetXYofAlarmingDevice" theStatus = "ok" theMessage = "Processed alarm xy: ND=" + theNodeName + ", ST=" + theNodeStatus + ", TI=" + theTransID + ", XY=" + theX.AsString + "," + theY.AsString retCode = false theParmList = {theScript,theStatus,theMessage,retCode} av.run("pbWriteAlarmLog", theParmList) end '*** Set the return parameters and return theParmList = {theTransID,theX,theY,theNodeName,theEquipName,theNodeStatus,true} _theX = theX _theY = theY _theNodeName = theNodeName _theEquipName = theEquipName _theNodeStatus = theNodeStatus _getXYRetCode = true Return theParmList