Accessing Numerical Codes

The numerical codes for classes, properties, coding groups and flag groups in inmation can be accessed using Lua. Examples are shown below.

Classes

Usage: syslib.model.classes.<class_name>

Example:

return syslib.model.classes.Core --returns 3

-- OR

local T = syslib.model.classes
return T.Core --returns 3

Properties

Usage: syslib.model.properties.<property_name>

Example:

return syslib.model.properties.ObjectName -- returns 1

-- OR

local T = syslib.model.properties
return T.ObjectName --returns 1
In the case of classes and properties , the values are loaded on demand so the properties will not be statically present in the table T if it is iterated.

Coding Groups

Usage: syslib.model.codes.<code_group_name>

Example:

return syslib.model.codes.SelectorGenItem.LUASCRIPT -- returns 5

-- OR

local T = syslib.model.codes.SelectorGenItem
return T.LUASCRIPT --returns 5

Code groups can also be referenced by their numerical code, see the example below.

return syslib.model.codes.SelectorGenItem[5] -- returns {"tag":"LUASCRIPT","meaning":"GenLuascript"}

-- OR

local T = syslib.model.codes.SelectorGenItem
return T[5] -- returns {"tag":"LUASCRIPT","meaning":"GenLuascript"}

Flag Groups

Usage: syslib.model.flags.<flag_group_name>.<flag>

Returns the flag, as shown above returns the numeric flag value not the bit position.

Example:

return syslib.model.flags.ItemValueStorageStrategy.STORE_RAW_HISTORY -- returns 1

-- OR

local T = syslib.model.flags.ItemValueStorageStrategy
return T.STORE_RAW_HISTORY --returns 1

-- OR

syslib.model.flags.ModUserState.STATE_GOOD -- returns 1024

Flag groups can also be referenced by their numerical code.

return syslib.model.flags.PlcType[0x8000] -- returns {"tag":"PLC_TYPE_REMOTE", "meaning":"Plc Type Remote"}

-- OR

local T = syslib.model.flags.PlcType
return T[0x8000] -- returns {"tag":"PLC_TYPE_REMOTE", "meaning":"Plc Type Remote"}

An example of checking which flags are set in an object’s flag group using Lua Check the ProfileUserAccessControl flag group of an Access Model Profile where the flags are set as shown below:

ProfileAccessUserControl Flag Group - Flags set in DataStudio
Figure 1. ProfileAccessUserControl Flag Group - Flags set in DataStudio

The following code uses bitwise operations to compare the flag group value against the individual flag values to identify the set flags.

local flagValue = syslib.getvalue("/Guest Users.ProfileUserAccess")

--bitwise operations to identify flags
local resultText = ""
if ((flagValue & syslib.model.flags.ProfileUserAccessControl.USR_ACC_CTRL_DATA_STUDIO) ~=0 ) then
    resultText = resultText .. "DataStudio, "
end
if ((flagValue & syslib.model.flags.ProfileUserAccessControl.USR_ACC_CTRL_DATA_WEB) ~=0 ) then
    resultText = resultText .. "SCI, "
end
if ((flagValue & syslib.model.flags.ProfileUserAccessControl.USR_ACC_CTRL_OPC_DA) ~=0 ) then
   resultText = resultText .. "DA, "
end
if ((flagValue & syslib.model.flags.ProfileUserAccessControl.USR_ACC_CTRL_OPC_HDA) ~=0 ) then
    resultText = resultText .. "HDA, "
end
if ((flagValue & syslib.model.flags.ProfileUserAccessControl.USR_ACC_CTRL_OPC_AE) ~=0 ) then
    resultText = resultText .. "AE, "
end
if ((flagValue & syslib.model.flags.ProfileUserAccessControl.USR_ACC_CTRL_OPC_UA) ~=0 ) then
    resultText = resultText .. "UA"
end

return resultText

For the pictured Access Model profile, this code returns "DataStudio, HAD, UA".

In the case of coding and flag groups, the table T already has the values loaded and can be iterated to find all existing codes and flags.

All information about classes, properties, codings and flags can be found on the System Model page.