semvec/pypi-packages huggingface dataset:
PyXGT 1.1
Python connect to PLC LS
Keywords: PLC,protocol,LS electric

# Python connect to PLC LS by TCP XGT Server

LS protocol(LS electric Communication Protocol) implementation by Python. LS protocol enables you to operate PLC from computer.

# import library

from PyXGT.LS import plc_ls

# connect to PLC

conn = plc_ls("192.168.1.10",2004) #PLC LS IP and port: 2004 (TCP XGT server)

# write device

val = conn.command("XGB", "write", "bit", "M70","1")# Write ON to Bit M70

val = conn.command("XGB", "write", "bit", "M70") or conn.command("XGB", "write", "bit", "M70","0") # Write OFF to Bit M70

val = conn.command("XGB", "write", "byte", "D100","20") # Write 20 to 100th Byte(int8) D50( beacause 1 D= int16)

val = conn.command("XGB", "write", "word", "D100","1") # write 1 to Word(int16) D100

val = conn.command("XGB", "write", "dword", "D50","1") # Write 1 to 50th doubleWord(int32)( D100-D101)

val = conn.command("XGB", "write", "lword", "D25","1") # Write 1 to 25th long(int64) ( D100-D101-d102-d103)

# read device

val = conn.command("XGB", "read", "bit", "M70") # read Bit M70 return [1] or [0]

val = conn.command("XGB", "read", "byte", "D100") # read 100th Byte(int8) D50( beacause 1 D= int16)

val = conn.command("XGB", "read", "word", "D100) # read Word(int16) D100

val = conn.command("XGB", "read", "dword", "D50) # read 50th doubleWord(int32)( D100-D101)

val = conn.command("XGB", "read", "lword", "D25) # read 25th long(int64) ( D100-D101-d102-d103)

# write multi device

val = conn.command("XGB", "write", "bit", "M70,M71,M72","1,0,1")# Write ON to Bit M70, OFF M71 and ON M72

val = conn.command("XGB", "write", "bit", "M70,M71,M72") # write off all 3 bits M70,M71,M72

.......................

# read multi device

val = conn.command("XGB", "read", "bit", "M70,M71,M72") # read 3 Bits M70,M71,M72 return [1,0,1]

.............................................
XGTserver 1.0
Python connect to PLC LS
Keywords: PLC,protocol,LS electric

# Python connect to PLC LS by TCP/IP

LS protocol(LS electric Communication Protocol) implementation by Python. LS protocol enables you to operate PLC from computer.

# import library

from XGTserver.LS import plc_ls

# connect to PLC

conn = plc_ls("host":"192.168.1.10", "port":2004)

# write device

val = conn.command("XGB", "write", "bit", "M70","1")# Write ON to Bit M70

val = conn.command("XGB", "write", "bit", "M70") or conn.command("XGB", "write", "bit", "M70","0") # Write OFF to Bit M70

val = conn.command("XGB", "write", "byte", "D100","20") # Write 20 to 100th Byte(int8) D50( beacause 1 D= int16)

val = conn.command("XGB", "write", "word", "D100","1") # write 1 to Word(int16) D100

val = conn.command("XGB", "write", "dword", "D50","1") # Write 1 to 50th doubleWord(int32)( D100-D101)

val = conn.command("XGB", "write", "lword", "D25","1") # Write 1 to 25th long(int64) ( D100-D101-d102-d103)

# read device

val = conn.command("XGB", "read", "bit", "M70") # read Bit M70 return [1] or [0]

val = conn.command("XGB", "read", "byte", "D100") # read 100th Byte(int8) D50( beacause 1 D= int16)

val = conn.command("XGB", "read", "word", "D100) # read Word(int16) D100

val = conn.command("XGB", "read", "dword", "D50) # read 50th doubleWord(int32)( D100-D101)

val = conn.command("XGB", "read", "lword", "D25) # read 25th long(int64) ( D100-D101-d102-d103)

# write multi device

val = conn.command("XGB", "write", "bit", "M70,M71,M72","1,0,1")# Write ON to Bit M70, OFF M71 and ON M72

val = conn.command("XGB", "write", "bit", "M70,M71,M72") # write off all 3 bits M70,M71,M72

.......................

# read multi device

val = conn.command("XGB", "read", "bit", "M70,M71,M72") # read 3 Bits M70,M71,M72 return [1,0,1]

.............................................