截止Plant Simulation 2404最全(常用)的属性操作说明
getAttribute【概述:通过属性名称获取当前属性是否处于继承状态,以及是否可以被继承】
<Path>.getAttribute(AttributeName:string[, byRef Inherited:boolean, byRef CanInherit:boolean]) → any
参数
数据类型字符串的参数AttributeName指定属性的值。
当将布尔数据类型的局部变量传递给可选参数Inherited时,如果字符串指定的属性继承了其值,则 Plant Simulation为该变量分配true ,如果不继承该值,则分配false 。
如果属性不能被继承,可选参数Inherited总是返回 false。
当将布尔数据类型的局部变量传递给可选参数CanInherit时,如果字符串指定的属性值可以继承,则 Plant Simulation为该变量分配true ,如果不能继承,则分配false 。
返回值
返回值的数据类型为 any。
// checks if inheritance of the attribute 'Accumulating' is active or not
var inherited: boolean
print MyConveyor.getAttribute("Accumulating", inherited)
print inherited
// Check if the source code of the Method is inherited
var bInherit:boolean
&Method.getAttribute("Program", bInherit)
print bInherit
getAttrName[概述:通个属性ID获取属性名称]
<Path>.getAttrName(AttributeNumber:integer) → string
范围
参数AttributeNumber的数据类型为整数,用于指定用户定义属性的名称。如果超出允许的索引范围,Plant Simulation将显示错误消息。
返回值
返回值的数据类型为字符串。
getAttrNo【通个属性名称获取属性编号】
<Path>.getAttrNo(AttributeName:string) → integer
范围
参数AttributeName为字符串数据类型,指定用户定义属性的名称。
返回值
返回值的数据类型为整数。
如果不存在具有指定AttributeName的用户定义属性,则返回 0。
param lookFor: string -> any
// checks if a user-defined object exists or not and
// returns its value if it exists
var index: integer := MyStation.getAttrNo(lookFor)
if index > 0
return MyStation.getAttrValue(index)
end
getAttrType【概述:通个属性编号获取属性类型】
范围
整数数据类型的参数AttributeNumber指定用户定义的属性。
返回值
返回值的数据类型为字符串。
// lists the data types of all user-defined attributes
for var index := 1 to MyStation.NumAttr
print MyStation.getAttrType(index)
next
getAttrValue【概述:通个属性id获取属性值】
范围
参数AttributeNumber为整数数据类型,指定用户定义的属性。值的数据类型取决于属性的类型。
返回值
返回值的数据类型为 any。
print MyStation.getAttrValue(1)
setAttribute【概述:通过属性名称设置属性值】
<Path>.setAttribute(AttributeName:string, Value:any)
参数
数据类型字符串的参数AttributeName指定属性。
数据类型为any 的参数Value指定值。
MyStation.setAttribute("ProcTime",5)
setAttrType【通过属性id 设置属性类型】
<Path>.setAttrType(AttributeNumber:integer, DataType:string) → boolean
参数
参数AttributeNumber为整数数据类型,指定用户定义属性的索引号。
数据类型字符串的参数 DataType指定其数据类型:boolean、int、real、string、object、table、list、stack、queue、time、money、length、weight、speed、accelercy、date、dateTime或randtime。
返回值
返回值的数据类型为boolean。
setAttrValue【概述:通个属性id设置属性值】
<Path>.setAttrValue(AttributeNumber:integer, Value:any) → boolean
参数
参数AttributeNumber为整数数据类型,指定用户定义属性的索引号。
数据类型为any 的参数Value指定其值。
返回值
返回值的数据类型为boolean。
var index: integer
index := MyStore.getAttrNo("Sale")
MyStore.setAttrValue(index,true)
createAttr【概述:创建用户属性】
<Path>.createAttr(AttributeName:string, DataType:string) → boolean
参数
参数AttributeName为字符串数据类型,指定用户定义属性的名称。
数据类型字符串的参数DataType指定其数据类型。
返回值
返回值的数据类型为boolean。
如果新名称或数据类型无效,则为 false。
MyStation.createAttr("lotsize","integer")
MyStation.createAttr("inventoryNo","string")
@.createAttr("Paint","boolean")
//注意创建的属性如何需要携带初始值(initValue)每次重置复位的值请按如下代码操作
mystation.lotsize.hasinitvalue=true //激活当前属性拥有初始化值
mystation.lotsize.initvalue=0 //设置初始化值
deleteAttr【删除用户定义的属性】
您只能删除已创建且未被继承的对象的用户定义属性。Plant Simulation会从该对象的所有实例中删除用户定义属性。
attributeWatchable【确认目标属性是否可以被watch】
返回
<Path>.attributeWatchable(AttributeName:string) → boolean
范围
参数AttributeName为字符串数据类型,指定属性或只读属性。
返回值
返回值的数据类型为boolean。
hasAttribute【判断当前属性是否存在】
返回
<Path>.hasAttribute(AttributeName:string) → boolean
范围
参数AttributeName的数据类型为字符串,指定您想知道对象是否具有的属性的名称。
返回值
返回值的数据类型为boolean。
如果对象具有可读取的属性,则为 true。
print Station.hasAttribute("Availability")
inheritAttribute[启用指定属性继承]
如果已关闭由
<Path>.<UserDefinedAttribute>.inheritAttribute(AttributeName:string)
范围
参数AttributeName为字符串数据类型,指定用户定义属性的属性名称。
NumAttr[获取用户自定义的属性数量(含继承的用户属性)]
<Path>.NumAttr
返回值
返回值的数据类型为整数。
var index: integer
for index := 1 to MyStation.NumAttr
print MyStation.getAttrName(index)
next
putAttributeNamesIntoTable
将
<Path>.putAttributeNamesIntoTable(Table:table)
<Path>.putAttributeNamesIntoTable(Table:table[, IncludeUserDefinedAttribute:boolean:=false, IncludeMethods:boolean:=false, Language:integer:=ModelLanguage])
参数
数据类型表的参数 Table指定表。
可选参数IncludeUserDefinedAttribute的数据类型为布尔值,用于确定Plant Simulation是否也将用户定义的属性写入表中(true)。如果输入false,Plant Simulation仅将内置属性的名称写入表中。
参数的默认值
默认值为 false。
可选参数IncludeMethods的数据类型为布尔值,用于确定Plant Simulation是否不仅将属性名称写入表中,还将方法名称和只读属性名称写入表中(true)。如果参数IncludeUserDefinedAttribute也为true布尔值,则Plant Simulation还会将用户定义方法和只读属性的名称写入表中。
参数的默认值
默认值为 false。
可选参数Language的数据类型为整数,用于设置Plant Simulation显示属性名称的语言。例如,0表示德语,1表示英语。如果不输入此参数,Plant Simulation将使用模型的语言显示属性名称。
参数的默认值
默认值是ModelLanguage。