View Full Version : Valve Tag Creation Function
robinsjg
01-26-2011, 06:36 AM
A client wants to track both manual valves and piping speciality items from within the Valve table. I've got everything set up so it does this correctly. However, since the tag codes are different, I would like to do an If statement from within the Valve Tag Creation function that will test for the tag type, whether it is a manual valve or piping speciality, and then do something different for each case. Is there anyway to do this?
Also, in a releated question, is there also a way to figure out the pipe size of the pipe you are creating the valve on? We include the valve size in the valve tag. Is there a way for it to automatically populate at least that portion of the tag number, based on the pipe you've clicked on?
I tried using at_asi_read_tab and at_asi_lastkey to read the value from the table but, of course, at that point the entry has not been added to the Valve table, so that didn't work.
PeterJ
01-28-2011, 11:46 AM
You can use the schema variable to detect the tag_type of the object you're placing (I always add AT_HVALVE_APP for all line appendages that are not valves, like sight glases, steam traps, ... ). Based on the tag_type you can run separate numbering routines.
I'll get you the variable for the pipe_run keytag later on. From there you can access all data in pipe_run table, and through LINE_ID (if existing) also the process table. That way you can pick up all values that form the line tag.
ps : I can help you develop the code for this (done it for dozens of P&ID users), even with incremental numbering by line or so.
robinsjg
02-07-2011, 08:52 AM
Peter,
Thanks for the help. Can you explain what exactly the schema variable is?
I think I can handle the majority of the code, but I just need to know how exactly to determine the tag type of the item you are placing from within that valve tag creation routine. And same goes for the pipe size that you are placing the item on. If you can tell me that, I think I can figure out the rest of the code to test for these values and run separate routines. I figured out how to grab values from the database, but the problem I ran in to in this case is that it actually hasn't create a record in the Valve table yet, so I'm not exactly where to get them from.
PeterJ
02-07-2011, 11:35 AM
The variable SCHEMA holds the tag_type of the object that is being placed. SCHEMA is the name of the field in settings database (all fields of the selected record are stored in variables when a symbol is placed, variable name corresponds with settings fieldname).
When a valve is inserted on a line, the variable RUNKEY holds the keytag of the run on which the valve is placed. From there, you can find all run data in PIPE_RUN table, and through its LINE_ID field you can find all process data in PROCESS.
Don't forget to check for empty values in case a valve is not placed on a line, or on a pipe-run without process.
Powered by vBulletin® Version 4.1.7 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.