Specify unique Smart Object instance values

For Smart Object (SO) instances that are an instance of a Smart Object definition, each instance can persist its own instance specific data (data unique to the instance of the SO). Instance-specific data can include values for:
  • Program parameters
  • Program local tags
  • Routine parameters
  • Routine local tags
  • Properties on the program or routine itself
Use this structure for specifying an instance value:
[ SO instance ] {
<Tag relative {from SO Instance) Qualified Name> := value
<Tag relative {from SO Instance) Qualified Name> { <member values }
}
Keep these guidelines in mind when using instance-specific values:
  • Instance-specific values apply to any inherited value, which can be:
    • From the SO instance’s definition.
    • From any definition the SO instance’s definition also extends, or inherits, from.
    • Any child SO instance that is contained within the SO instance.
    • Any child SO instance inherited.
  • Instance-specific values are only specified when the value within the instance is different than the value from the definition. In cases where the definition does not specify a value, the value in the definition is zero.
  • Instance-specific values can be specified on a scalar tag, a complex typed tag or parameter, such as arrays or structure tags, or a specific bit on a scalar typed tag or parameter.
  • Instance-specific data also applies to definitions extending other definitions. A derived definition may have “instance specific data” different than the definition it extends.
These examples show Smart Object syntax.
Situation
Example
Smart Object definition with values assigned to tags contained within the SO
so MySODef {
program p1(input dint pIn1 := 6, output dint pOut1 := 6) {
tag dint progTag; // note: value was not specified and thus has value of 0
routine ld r1 (input dint rIn1 := 6) {
tag dint routTag := 6;
}
}
}
model Area {
MySODef Inst1;
MySODef Inst2;
}
/////////////////////////////////////////
// Showing the file makeup.
// programs are in a sub-directory (directory name is the program name)
SO definition file: MySODef.smo
so MySODef {
// program declaration
// or forward declaration. This
// signature must match the program
// implementation.
extern program p1(input dint pIn1,
output dint pOut1);
}
Program implementation file: p1\p1.logix
program MySODef.p1(input dint pIn1 := 6,
output dint pOut1 := 6) {
tag dint progTag; // note: value
// was not
// specified and
// thus has value
// of 0
// routine declaration
// or forward declaration. This
// signature must match the routine
// implementation.
extern routine r1(input dint rIn1);
}
}
Routine implementation file: p1\r1.logix
// must declare routine type here
// can specify parameter values here
routine ld r1(input dint rIn1) {
tag dint routTag := 6;
}
Area model file: Area.model
model Area {
MySODef Inst1;
MySODef Inst2;
}
SO instances with instance-specific values
model Area {
MySODef Inst1 {
p1.pIn1 := 10;
p1.pOut1 := 10;
p1.progTag := 10;
p1.r1.rIn1 := 10;
p1.r1.routTag := 10;
}
}
SO instances with structured instance-specific values
model Area {
MySODef Inst1 {
p1.someStructTag {
mem1 := 5; /// specific member
mem2 {
.1 := 1; /// specific bit of a specific member
}
}
SO definition with instance- specific values – extending from base
so MySODef {
program p1(input dint pIn1 := 6, output dint pOut1 := 6) {
tag dint progTag; // note: value was not specified and thus has value of 0
routine ld r1 (input dint rIn1 := 6) {
tag dint routTag := 6;
}
}
}
SO myExtendedSODef extends MySODef {
p1.pIn1 := 10;
p1.pOut1 := 10;
p1.progTag := 10;
p1.r1.rIn1 := 10;
p1.r1.routTag := 10;
}
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.