def get_orders(self): """ Retrieve the amount of currently placed orders. :return: The order count. """ state_value = application.Disconnected().modbus_value if self.is_connected(): try: state_value = self.modbus_client.read_holding_registers( int(ModbusTCPRegisters.Orders), 1).registers[0] except: pass return state_value
def set_reset(self): """ Initiate the reset signal to get the PLC out of the emergency stop state. :return: The PLC connectors response, so it can be use if of interest. """ state_value = application.Disconnected().modbus_value if self.is_connected(): try: state_value = self.modbus_client.write_register( int(ModbusTCPRegisters.Reset), 1) except: pass return state_value
def get_application_state(self): """ Query the application state. :return: A dictionary containing the current application state. """ state_value = application.Disconnected().modbus_value if self.is_connected(): try: state_value = \ self.modbus_client.read_holding_registers(int(ModbusTCPRegisters.PlcApplicationState), 1).registers[ 0] except: pass return state_value
def set_application_state(self, state): """ Set the current application state. :param state: :return: The PLC connectors response, so it can be use if of interest. """ state_value = application.Disconnected().modbus_value if self.is_connected(): try: state_value = self.modbus_client.write_register( int(ModbusTCPRegisters.HmiApplicationState), state.modbus_value) except: pass return state_value
def set_motor(self, motor, motor_state): """ Turn a motor of the process manually on or off. :param motor: Which motor is to be set. :param motor_state: On or Off. :return: The PLC connectors response, so it can be use if of interest. """ register = self.motor_controls[motor] state_value = application.Disconnected().modbus_value if self.is_connected(): try: state_value = self.modbus_client.write_register( register, int(motor_state)) except: pass return state_value
def test_disconnected(self): DisconnectedState = app_states.Disconnected() assert DisconnectedState.modbus_value == 3 assert DisconnectedState.text == "DISCONNECTED" assert DisconnectedState.name == "disconnected" assert DisconnectedState.classes == ["btn btn-info mr-auto"]