• No results found

EDEN Translator Required VB Editing

In document Pds Guide (Page 86-90)

Depending on the graphics and the code in the EDEN file, you may need to make some modifications after the utility finishes translating the EDEN code to Visual Basic code. These edits are due to some of the limitations of the translator due to the dissimilarities in the way a symbol is defined in EDEN and the way in which a symbol is defined in Visual Basic. Known issues are identified below.

Symbol Inputs in EDEN (Dimension_* variables)

EDEN has some general purpose variables that are used to store certain user defined values. These variables will most probably be symbol inputs in Visual Basic.

Whenever such variables are encountered, the translator automatically treats them as symbol Inputs. For example:

height = Dimension_34 - Dimension_37

The translator generates the code as follows:

Dim height As Variant

height = Dimension(34) - Dimension(37)

It also automatically adds the symbol inputs:

m_oSymbolHelper.AddInputDef 3, "Dimension(34)", "Dimension(34)", 3 m_oSymbolHelper.AddInputDef 4, "Dimension(37)", "Dimension(37)", 4

Note, that in Visual Basic the symbol input can be called by some other name, say,

"ImpellerDiameter", "PumpHeight", and so forth. You will have to modify the name of the input to match the one that is defined in the excel data files. For example, you can modify the generated code as follows:

m_oSymbolHelper.AddInputDef 3, "ImpellerDiameter",

"ImpellerDiameter", 3

Connect Points with Cylinder (Piping)

In EDEN, a cylinder is drawn separately from the Connect Point. However, in Visual Basic there is a mechanism to draw the Cylinder along with the Nozzle (that is, use the length property of the nozzle). It is not possible for the translator to determine which connect point in EDEN goes with which cylinder. Therefore, the translator simply translates the code as is. Thus, it generates two overlapping cylinders in Visual Basic. This overlap is just a runtime overhead of drawing an extra cylinder for each nozzle. You may want to remove the code that draws the graphic for the cylinder if you are sure that the graphic for the nozzle will suffice to represent the symbol and thus the extra cylinder is redundant. You will also have to remove the output

declaration in the symbol initialize, if you choose to do this.

If-Then-Else Conditions

EDEN does not require you to declare all the outputs of a symbol beforehand.

However, in Visual Basic you are required to list all the outputs of a symbol in the initialization of the User Symbol Services object. If some graphics are drawn within an If-Then-Else condition, then the translator has no way of knowing which object should be drawn at runtime. The current implementation of the translator is such that it lists all the objects in the outputs. You are required to modify the code depending upon which outputs will be used. For example:

The EDEN code looks like this:

If ( Body_OD_1 .EQ. Body_OD_2 ) Then

Call Draw_Cylinder_With_Capped_Ends ( length, Body_OD_1 ) Else

Call Draw_Cone_With_Capped_Ends ( length, Body_OD_1, Body_OD_2 ) Endif

Depending upon the condition, either a cylinder or a cone will be drawn, but not both.

The translator generates the Visual Basic code as:

If (oNozzleData(1).dPipeDiameter = oNozzleData(2).dPipeDiameter) Then

oT4x4Temp.LoadIdentity

oT4x4Temp.IndexValue(12) = length Dim oCylinderCapped2 As Object

Set oCylinderCapped2 = PlaceCylinder(m_OutputColl, oOriginPos, oT4x4Temp.TransformPosition(oOriginPos),

CDbl(oNozzleData(1).dPipeDiameter), True oCylinderCapped2.Transform oT4x4Current oOutputCol.Add oCylinderCapped2

oT4x4Current.MultMatrix oT4x4Temp Else

oT4x4Temp.LoadIdentity

oT4x4Temp.IndexValue(12) = length Dim oConeCapped1 As Object

Set oConeCapped1 = PlaceCone(m_OutputColl, oOriginPos, oT4x4Temp.TransformPosition(oOriginPos),

CDbl(oNozzleData(1).dPipeDiameter) / 2,

CDbl(oNozzleData(2).dPipeDiameter) / 2, True) oConeCapped1.Transform oT4x4Current

oOutputCol.Add oConeCapped1

oT4x4Current.MultMatrix oT4x4Temp End If

The translator also adds both the outputs in the symbol initialization:

m_oSymbolHelper.AddOutputDef 1, "oCylinderCapped1",

"oCylinderCapped1", 1

m_oSymbolHelper.AddOutputDef 2, "oCylinderCapped2",

"oCylinderCapped2", 1

This causes a problem at runtime because one of the outputs will be "Nothing" at runtime. To avoid this problem, remove the extra output as follows:

m_oSymbolHelper.AddOutputDef 1, "oCylinderorCone1",

"oCylinderorCone1", 1

Note

Remember that you will also have to edit the

m_oSymbolHelper.NumOutputs (in the same initialize method) appropriately.

The symbol graphics code may also be modified for better readability, however the code will function even if it is not modified.

Note

In some cases, where the statements in the If-Then-Else are more

complex, then more modifications may be necessary. Example of this may be when two graphics are drawn in the "if" case and only one is drawn in the "else" case.

Approximations to Zero

Visual Basic symbols have difficulty in drawing cones with zero radii. In these cases, the generated code will compile successfully, however, at runtime it may raise some problems from the math calculations. This is avoided by changing the value of zero to a value that is very close to zero. For example:

Dim diameter As Variant

diameter = DELTA_TOLERANCE ' 0#

Set oCone1 = PlaceCone(..) ' this call uses the `diameter' variable

In the above code, a value of zero is replaced with a value of "0.00001". The DELTA_TOLERANCE constant is defined for this purpose.

Aspects (Equipment)

Symbols in Equipment can have aspects, and each graphic that is drawn can belong to one or many aspects. In Visual Basic we handle aspects by having separate ".cls" file for each aspect (for those symbols not using SmartEquipment). The translator does not generate separate code for each aspect. Thus, the code generated will not contain any information on the aspects. All the code generated will belong only to the

SimplePhysical aspect. You will have to cut, copy and paste portions of the code into different aspects as needed.

Nozzles (Equipment)

Equipment nozzles are now defined with a PlaceHolder in the symbol file and the actual nozzle is placed in a "_Def.cls" file. The translator does not generate this "Def"

file automatically. You will have to generate this file either with the wizard or by copying this file from another symbol and editing it as needed.

Draw Complex Surface

The Draw Complex Surface primitive does not add the symbol inputs to the Initialize method in the USS symbol object. This is because several Draw Complex Surface, Draw Line, and Draw Arc calls result in a single surface being drawn and thus adding the output automatically is not supported at this time. However, you can add the output as follows:

m_oSymbolHelper.AddOutputDef 1, "ComplexSurface1",

"ComplexSurface1", 1

Note

Remember that you will also have to edit the

m_oSymbolHelper.NumOutputs (in the same initialize method) appropriately.

Removal of User Input Code (Equipment)

The Equipment EDEN modules have code that is related with getting and displaying some information from/to the user through the forms interface. This code has no meaning in Visual Basic and this should be removed from the Visual Basic symbol code. This code is generally contained within a Do…Loop statement and looks similar to this:

Do While (accepted = 0) If (LAST_INP_TYPE = USER_KEYIN) Then .. ..

Loop

Related Topics

Converting PDS EDEN to SmartPlant Visual Basic Symbols: An Overview, page 83

In document Pds Guide (Page 86-90)

Related documents