def test_client_server(self): ADDRESS = 'localhost:44818' try: # same instance used as server and client enip = EnipProtocol( protocol=TestEnipProtocol.CLIENT_SERVER_PROTOCOL) # read a multikey what = ('SENSOR1', 1) enip._receive(what, ADDRESS) # read a single key what = ('ACTUATOR1',) enip._receive(what, ADDRESS) # write a multikey what = ('SENSOR1', 1) for value in range(5): enip._send(what, value, ADDRESS) # write a single key what = ('ACTUATOR1',) for value in range(5): enip._send(what, value, ADDRESS) EnipProtocol._stop_server(enip._server_subprocess) except Exception as error: EnipProtocol._stop_server(enip._server_subprocess) print 'ERROR test_client_server: ', error assert False
def test_send_multikey(self): enip = EnipProtocol( protocol=TestEnipProtocol.CLIENT_PROTOCOL) ADDRESS = 'localhost:44818' # TEST port TAGS = (('SENSOR1', 1, 'INT'), ('ACTUATOR1', 'INT')) try: server = EnipProtocol._start_server(ADDRESS, TAGS) # write a multikey what = ('SENSOR1', 1) for value in range(5): enip._send(what, value, ADDRESS) # write a single key what = ('ACTUATOR1',) for value in range(5): enip._send(what, value, ADDRESS) EnipProtocol._stop_server(server) except Exception as error: EnipProtocol._stop_server(server) print 'ERROR test_send_multikey: ', error assert False
def test_receive_multikey(self): enip = EnipProtocol( protocol=TestEnipProtocol.CLIENT_PROTOCOL) ADDRESS = 'localhost:44818' # TEST port TAGS = (('SENSOR1', 1, 'INT'), ('ACTUATOR1', 'INT')) try: server = EnipProtocol._start_server(ADDRESS, TAGS) # read a multikey what = ('SENSOR1', 1) address = 'localhost:44818' enip._receive(what, ADDRESS) # read a single key what = ('ACTUATOR1',) address = 'localhost:44818' enip._receive(what, ADDRESS) EnipProtocol._stop_server(server) except Exception as error: EnipProtocol._stop_server(server) print 'ERROR test_receive_multikey: ', error assert False
def test_client_server(self): try: enip = EnipProtocol( protocol=CLIENT_SERVER_PROTOCOL) # read a multikey what = ('SENSOR1', 1) address = 'localhost:44818' enip._receive(what, address) # read a single key what = ('ACTUATOR1',) address = 'localhost:44818' enip._receive(what, address) # write a multikey what = ('SENSOR1', 1) address = 'localhost:44818' for value in range(5): enip._send(what, value, address) # write a single key what = ('ACTUATOR1',) address = 'localhost:44818' for value in range(5): enip._send(what, value, address) EnipProtocol._stop_server(enip._server_subprocess) except Exception as error: EnipProtocol._stop_server(enip._server_subprocess) print 'ERROR test_client_server: ', error
def test_client_server(self): try: enip = EnipProtocol(protocol=CLIENT_SERVER_PROTOCOL) # read a multikey what = ('SENSOR1', 1) address = 'localhost:44818' enip._receive(what, address) # read a single key what = ('ACTUATOR1', ) address = 'localhost:44818' enip._receive(what, address) # write a multikey what = ('SENSOR1', 1) address = 'localhost:44818' for value in range(5): enip._send(what, value, address) # write a single key what = ('ACTUATOR1', ) address = 'localhost:44818' for value in range(5): enip._send(what, value, address) EnipProtocol._stop_server(enip._server_subprocess) except Exception as error: EnipProtocol._stop_server(enip._server_subprocess) print 'ERROR test_client_server: ', error
def test_receive_multikey(self): enip = EnipProtocol( protocol=CLIENT_PROTOCOL) TAGS = (('SENSOR1', 1, 'INT'), ('ACTUATOR1', 'INT')) cmd = EnipProtocol._start_server_cmd(tags=TAGS) try: server = subprocess.Popen(cmd, shell=False) # read a multikey what = ('SENSOR1', 1) address = 'localhost:44818' enip._receive(what, address) # read a single key what = ('ACTUATOR1',) address = 'localhost:44818' enip._receive(what, address) EnipProtocol._stop_server(server) except Exception as error: EnipProtocol._stop_server(server) print 'ERROR test_client: ', error
def test_send_multikey(self): enip = EnipProtocol(protocol=CLIENT_PROTOCOL) TAGS = (('SENSOR1', 1, 'INT'), ('ACTUATOR1', 'INT')) cmd = EnipProtocol._start_server_cmd(tags=TAGS) try: server = subprocess.Popen(cmd, shell=False) # write a multikey what = ('SENSOR1', 1) address = 'localhost:44818' for value in range(5): enip._send(what, value, address) # write a single key what = ('ACTUATOR1', ) address = 'localhost:44818' for value in range(5): enip._send(what, value, address) EnipProtocol._stop_server(server) except Exception as error: EnipProtocol._stop_server(server) print 'ERROR test_client: ', error
def test_client_server(self): ADDRESS = 'localhost:44818' try: # same instance used as server and client enip = EnipProtocol( protocol=TestEnipProtocol.CLIENT_SERVER_PROTOCOL) # read a multikey what = ('SENSOR1', 1) enip._receive(what, ADDRESS) # read a single key what = ('ACTUATOR1', ) enip._receive(what, ADDRESS) # write a multikey what = ('SENSOR1', 1) for value in range(5): enip._send(what, value, ADDRESS) # write a single key what = ('ACTUATOR1', ) for value in range(5): enip._send(what, value, ADDRESS) EnipProtocol._stop_server(enip._server_subprocess) except Exception as error: EnipProtocol._stop_server(enip._server_subprocess) print('ERROR test_client_server: ', error) assert False
def test_server_stop(self): cmd = EnipProtocol._start_server_cmd() try: server = subprocess.Popen(cmd, shell=False) EnipProtocol._stop_server(server) except Exception as error: print 'ERROR test_server_stop: ', error
def test_server_multikey(self): TAGS = (('SENSOR1', 1, 'INT'), ('ACTUATOR1', 'INT')) cmd = EnipProtocol._start_server_cmd(tags=TAGS) try: server = subprocess.Popen(cmd, shell=False) EnipProtocol._stop_server(server) except Exception as error: print 'ERROR test_server_multikey: ', error
def test_server_multikey(self): ADDRESS = 'localhost:44818' # TEST port TAGS = (('SENSOR1', 1, 'INT'), ('ACTUATOR1', 'INT')) try: server = EnipProtocol._start_server(ADDRESS, TAGS) EnipProtocol._stop_server(server) except Exception as error: print 'ERROR test_server_multikey: ', error assert False
def test_init_server(self): try: server = EnipProtocol( protocol=TestEnipProtocol.CLIENT_SERVER_PROTOCOL) eq_(server._name, 'enip') server._stop_server(server._server_subprocess) del server except Exception as error: print 'ERROR test_init_server: ', error assert False