Пример #1
0
def main():
    """main"""
    simu = MySimulator(TcpServer())

    try:
        LOGGER.info("'quit' for closing the server")
        simu.start()

    except Exception as excpt:
        print excpt

    finally:
        simu.close()
Пример #2
0
def main():
    """main"""
    simu = MySimulator(TcpServer())

    try:
        LOGGER.info("'quit' for closing the server")
        simu.start()

    except Exception as excpt:
        print excpt

    finally:
        simu.close()
Пример #3
0
def main():
    """main"""

    # Connect to the slave
    if "rtu" in sys.argv:
        server = RtuServer(serial.Serial(port=sys.argv[-1]))
    else:
        server = TcpServer()

    simu = MySimulator(server)

    try:
        LOGGER.info("'quit' for closing the server")
        simu.start()

    except Exception as excpt:
        print(excpt)

    finally:
        simu.close()
Пример #4
0
def main():
    """main"""

    #Connect to the slave
    if 'rtu' in sys.argv:
        server = RtuServer(serial.Serial(port=sys.argv[-1]))
    else:
        server = TcpServer(error_on_missing_slave=True)

    simu = MySimulator(server)

    try:
        LOGGER.info("'quit' for closing the server")
        simu.start()

    except Exception as excpt:
        print(excpt)

    finally:
        simu.close()
Пример #5
0
            values.append(int(val))

        #custom rules: if the value of reg0 is greater than 30 then reg1 is set to 1
        if address == 0 and values[0] > 30:
            try:
                values[1] = 1
            except:
                values.append(1)

        #operates on slave 1 and block foo
        slave = self.server.get_slave(1)
        slave.set_values("foo", address, values)

        #get the register values for info
        values = slave.get_values("foo", address, len(values))
        return self._tuple_to_str(values)


if __name__ == "__main__":
    simu = MySimulator()

    try:
        LOGGER.info("'quit' for closing the server")
        simu.start()

    except Exception, excpt:
        print excpt

    finally:
        simu.close()
Пример #6
0
            values.append(int(val))
        
        #custom rules: if the value of reg0 is greater than 30 then reg1 is set to 1
        if address==0 and values[0]>30:
            try:
                values[1] = 1
            except:
                values.append(1)
        
        #operates on slave 1 and block foo
        slave = self.server.get_slave(1)
        slave.set_values("foo", address, values)
        
        #get the register values for info
        values = slave.get_values("foo", address, len(values))
        return self._tuple_to_str(values)

if __name__ == "__main__":
    simu = MySimulator()
    
    try:
        LOGGER.info("'quit' for closing the server")
        simu.start()
        
    except Exception, excpt:
        print excpt
            
    finally:
        simu.close()