예제 #1
0
    def __init__(self, datatable):
        """datatable (object) = An object which provides methods for
		reading and writing the data table. The ones expected are:
		1) GetCoilsBool = Read a single coil.
		2) GetDiscreteInputsBool = Read a single discrete input.
		3) GetHoldingRegistersInt = Read a single holding register.
		4) GetInputRegistersInt = Read a single input register.
		5) SetCoilsBool = Write to a single coil.
		6) SetHoldingRegistersInt = Write to a single holding register.

		Routines to access extended data types are handled through a
		separate object, which is given a reference to the same data table.
		"""
        self._DataTable = datatable
        # This handles extended data types. These are data types which
        # span several adjacent registers.
        self._ExtData = ModbusExtData.ExtendedDataTypes(self._DataTable)
# Get the command line parameter options.
#CmdOpts = HMIServerCommon.GetOptionsClient(502, _HelpStr)

############################################################

# Initialise the client. First get the remote host parameters.
#hbhost, hbport, hbtimeout, hbunitid = CmdOpts.GetRemoteParams()

#Initialize an instance of the ModbusClient.DataTableAccess to initialize this client.

#HBClient = ModbusClient.DataTableAccess(hbhost, hbport, hbtimeout, hbunitid)
#HBClient1 = ModbusClient.DataTableAccess('192.168.10.237', 1502, 5.0, 1)

recDataClient2 = ModbusClient.DataTableAccess('10.0.0.100', 1502, 5.0, 1)

ExtData5 = ModbusExtData.ExtendedDataTypes(recDataClient2)

############################################################

#record_mode = int(raw_input("Enter 0 to record Train, and 1 to record Replay: "))

while True:

    replay_mode = recDataClient2.GetCoilsBool(
        32)  #1 for replay start, 0 when done

    while not replay_mode:
        replay_mode = recDataClient2.GetCoilsBool(32)

    recDataClient2.SetCoilsBool(40, 0)
예제 #3
0
# Get the command line parameter options.
#CmdOpts = HMIServerCommon.GetOptionsClient(502, _HelpStr)

############################################################

# Initialise the client. First get the remote host parameters.
#hbhost, hbport, hbtimeout, hbunitid = CmdOpts.GetRemoteParams()

#Initialize an instance of the ModbusClient.DataTableAccess to initialize this client.

#HBClient = ModbusClient.DataTableAccess(hbhost, hbport, hbtimeout, hbunitid)

#HBClient1 = ModbusClient.DataTableAccess('192.168.10.237', 1502, 5.0, 1)
PDClient1 = ModbusClient.DataTableAccess('10.0.0.100', 1502, 5.0, 1)

ExtData2 = ModbusExtData.ExtendedDataTypes(PDClient1)

############################################################

#file2 = open("truckHeading.dat","w")
#file2.write( "0" + '\t' + "0" + '\t' + "0" + '\t' + "0" + '\n' )
#file2.close()
choice = int(raw_input("\nEnter start position code: "))

file = open("truckPurple.dat", "w")

while True:

    valVF = ExtData2.GetInpRegFloat32(20)
    valVL = ExtData2.GetInpRegFloat32(22)
예제 #4
0
# Get the command line parameter options.
#CmdOpts = HMIServerCommon.GetOptionsClient(502, _HelpStr)

############################################################

# Initialise the client. First get the remote host parameters.
#hbhost, hbport, hbtimeout, hbunitid = CmdOpts.GetRemoteParams()

#Initialize an instance of the ModbusClient.DataTableAccess to initialize this client.

#HBClient = ModbusClient.DataTableAccess(hbhost, hbport, hbtimeout, hbunitid)

#HBClient1 = ModbusClient.DataTableAccess('192.168.10.237', 1502, 5.0, 1)
HBClient1 = ModbusClient.DataTableAccess('10.0.0.100', 1502, 5.0, 1)

ExtData1 = ModbusExtData.ExtendedDataTypes(HBClient1)

############################################################

file2 = open("truckHeading.dat", "w")
file2.write("0" + '\t' + "0" + '\t' + "0" + '\t' + "0" + '\n')
file2.close()

file = open("truckxy.dat", "w")

old_head = 0
new_head = 0
x = 1
VF_1 = 0
VL_1 = 0
VF_2 = 0
예제 #5
0
# Get the command line parameter options.
#CmdOpts = HMIServerCommon.GetOptionsClient(502, _HelpStr)

############################################################

# Initialise the client. First get the remote host parameters.
#hbhost, hbport, hbtimeout, hbunitid = CmdOpts.GetRemoteParams()

#Initialize an instance of the ModbusClient.DataTableAccess to initialize this client.

#HBClient = ModbusClient.DataTableAccess(hbhost, hbport, hbtimeout, hbunitid)
#HBClient1 = ModbusClient.DataTableAccess('192.168.10.237', 1502, 5.0, 1)

recDataClient1 = ModbusClient.DataTableAccess('10.0.0.100', 1502, 5.0, 1)

ExtData3 = ModbusExtData.ExtendedDataTypes(recDataClient1)

############################################################

#record_mode = int(raw_input("Enter 0 to record Train, and 1 to record Replay: "))

while True:

    #ExtData3.SetHRegStr16(100,30,"Press Start to Train Route")

    train_mode = recDataClient1.GetCoilsBool(
        31)  #1 for train start, 0 for train stop

    while not train_mode:
        train_mode = recDataClient1.GetCoilsBool(31)
예제 #6
0
	return a
'''
############################################################

# Initialise the client. First get the remote host parameters.
#hbhost, hbport, hbtimeout, hbunitid = CmdOpts.GetRemoteParams()

#Initialize an instance of the ModbusClient.DataTableAccess to initialize this client.

#HBClient = ModbusClient.DataTableAccess(hbhost, hbport, hbtimeout, hbunitid)

#HBClient1 = ModbusClient.DataTableAccess('192.168.10.237', 1502, 5.0, 1)

replayDataClient1 = ModbusClient.DataTableAccess('10.0.0.100', 1502, 5.0, 1)

ExtData4 = ModbusExtData.ExtendedDataTypes(replayDataClient1)

############################################################

while True:

    replay_mode = replayDataClient1.GetCoilsBool(
        32)  #1 for replay start, 0 when done

    while not replay_mode:
        replay_mode = replayDataClient1.GetCoilsBool(32)

    replayDataClient1.SetCoilsBool(
        40, 0)  #Setting record mode to record replay data [temp]

    #	replayDataClient1.SetCoilsBool(12,1) #Starting Homing
예제 #7
0
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with MBLogic. If not, see <http://www.gnu.org/licenses/>.
#
# Important:	WHEN EDITING THIS FILE, USE TABS TO INDENT - NOT SPACES!
##############################################################################

from mbprotocols import ModbusMemTable
from mbprotocols import ModbusExtData

##############################################################################
"""
This module creates the Modbus memory map (data table) to allow it to be 
directly imported into the various services. This is a global program resource 
with only once instance which is why ModbusMemTable can't be created multiple 
times. The structure of the Twisted server prevents creating it in the main 
module and passing to the various server protocol implementations.

Also created is an object for storing and retrieving extended data types 
(multi-register) in a Modbus data table.
"""

# Create the data table.
MemMap = ModbusMemTable.ModbusMemTable()

# Extended data types.
MemExtData = ModbusExtData.ExtendedDataTypes(MemMap)

예제 #8
0
# Get the command line parameter options.
#CmdOpts = HMIServerCommon.GetOptionsClient(502, _HelpStr)

############################################################

# Initialise the client. First get the remote host parameters.
#hbhost, hbport, hbtimeout, hbunitid = CmdOpts.GetRemoteParams()

#Initialize an instance of the ModbusClient.DataTableAccess to initialize this client.

#HBClient = ModbusClient.DataTableAccess(hbhost, hbport, hbtimeout, hbunitid)
#textDisplayClient1 = ModbusClient.DataTableAccess('192.168.10.226', 1502, 5.0, 1)

textDisplayClient1 = ModbusClient.DataTableAccess('10.0.0.100', 1502, 5.0, 1)

ExtData6 = ModbusExtData.ExtendedDataTypes(textDisplayClient1)

############################################################

STATE = "NULL"
#record_mode = int(raw_input("Enter 0 to record Train, and 1 to record Replay: "))

while True:

    ExtData6.SetHRegStr16(100, 30, "Welcome to S2!")

    time.sleep(5)

    mon = Monitor(STATE)  #Threading
    mon.start()  #Threading