beckhoff TE1000 — 5.9.3.1 Read

How To | Reading / Writing Data Create a session to the PLC (Port 851) of a target system, determine the SymbolHandle by InstancePath and use this handle to read its 'Int16' Value (INT on PLC System). Accessing Complex Objects (e.g Structs or FBs) Also complex types will be resolved transparently. E.g. a DT type with 3 fields (vBool, vInt, vString) on the PLC side can be accessed as a whole. Reading the Symbol Information PS> $symbol2 = $session | Get-TcSymbol -path 'MAIN.vmSimpleStruct' Getting the value of the struct.

The subvalues will be created type-safe on-the-fly as .NET Types PS> $val2 = $symbol2 | Read-TcValue PS> $val2 vBool vInt vString PSValue ----- ---- ------- ------- True -12121 QWERTZUIOPЬASDFGHJKLЦДYXCVBNM;:_ ... PS> $val2 | Get-Member TypeName: System.Management.Automation.PSCustomObject Name MemberType Definition ---- ---------- ---------- Equals Method bool Equals(System.Object obj) GetHashCode Method int GetHashCode() GetType Method type GetType() ToString Method string ToString() PSValue NoteProperty DynamicValue PSValue=...

vBool NoteProperty bool vBool=True vInt NoteProperty short vInt=-12121 vString NoteProperty string vString=QWERTZUIOPЬASDFGHJKLЦДYXCVBNM;:_ Also SubValues can be accessed. This doesn’t trigger a new ADS Read (and uses internally cached data). The data is consistent to the timepoint of the ‘Read-TcValue’ PS> $val2.vString QWERTZUIOPЬASDFGHJKLЦДYXCVBNM;:_ To access the more detailed internal Data of the Value, the ‘PSValue’ can be accessed.

PS> $val2.PSValue Symbol DataType ByteSize TimeStamp CachedRaw ------ -------- -------- --------- --------- MAIN.vmSimpleStruct ST_SimpleStruct 165 2024-01-11T15:24:33 01 A7 D0 51 00 57 00 45 00 52 00 54 00 5A 00 55 PS> $val2.PSValue | format-list * ValueFactory : TwinCAT.ValueAccess.DynamicValueFactory TimeStamp : 1/11/2024 3:24:33 PM +01:00 Symbol : MAIN.vmSimpleStruct (IG: 0x4040, IO: 0x10e7b8, Size: 165 bytes)' UpdateMode : None ParentValue : RootValue : ... Age : 00:07:18.2760087 DataType : ST_SimpleStruct CachedRaw : System.ReadOnlyMemory [165] IsPrimitive : False vBool : True vInt : -12121 vString : QWERTZUIOPЬASDFGHJKLЦДYXCVBNM;:_ TE1000 25 Version: 1.5.0