Ejemplo n.º 1
0
            raise
        valid_data = set([0,1,2])
        for i in sensor_data:
          if i not in valid_data:
             raise
          
        self.instrument.write_registers( address, self.update_moisture_sensor_configuration_addr ,sensor_data )
  


        
 
if __name__ == "__main__": 
       import new_instrument
       import time
       new_instrument  =  new_instrument.Modbus_Instrument()
       new_instrument.set_ip(ip= "192.168.1.84", port = 5005)       
       
       psoc_moisture = PSOC_4M_MOISTURE_UNIT( new_instrument )

       
       #psoc_moisture.update_current_time( 40 )
       #print psoc_moisture.clear_new_moisture_data_flag(40)
       print psoc_moisture.check_status(40)

       print psoc_moisture.check_one_wire_presence(40)
       time.sleep(.3)
       print psoc_moisture.make_soil_temperature(40)
       time.sleep(.3)
       print psoc_moisture.make_air_temp_humidity(40)
       time.sleep(.3)
        if len(sensor_data) != self.sensor_length:
            raise
        valid_data = set([0, 1, 2])
        for i in sensor_data:
            if i not in valid_data:
                raise ValueError(
                    "Bad Value for Sensor should be 0,1 or 2 Got " + i)
        self.instrument.set_ip(self.ip, self.port)
        self.instrument.write_registers(
            self.slave_address, self.update_moisture_sensor_configuration_addr,
            sensor_data)


if __name__ == "__main__":
    import new_instrument
    client_driver = new_instrument.Modbus_Instrument()
    moisture_controller = PSOC_4M_MOISTURE_UNIT("192.168.1.82", 5005, 40,
                                                client_driver)

    print "time", moisture_controller.read_time()
    print time.time()
    print moisture_controller.clear_new_moisture_data_flag()
    print moisture_controller.check_status()

    print moisture_controller.check_one_wire_presence()
    time.sleep(.3)
    print moisture_controller.make_soil_temperature()
    time.sleep(.3)
    print moisture_controller.make_air_temp_humidity()
    time.sleep(.3)
    print moisture_controller.make_air_temp_humidity()
Ejemplo n.º 3
0
 def __init__( self, remotes,address ):
     #self.instrument =   myModbus_udp.Instrument_UDP()  # 10 is instrument address
     self.new_instrument =  new_instrument.Modbus_Instrument()
     self.remotes          = remotes
     
     self.new_instrument.set_ip(address)