예제 #1
0
    def createSensors(self):

        attrs = ut.readConfig(self.conf_path, "DEFINE_SENSORS", 1)
        macs = ut.readConfig(self.conf_path, "SENSORS_MAC", 0)

        attrs = ut.formatAttrs(attrs)

        sensors = []
        for mac in macs:
            sensors.append(Sensor(self, attrs, mac[0], mac[1], mac[2]))

        return sensors, attrs, macs
예제 #2
0
	def createModules(self):
		attrs = ut.readConfig(self.conf_path, "DEFINE_MODULES", 1)
		macs = ut.readConfig(self.conf_path, "MODULES_MAC", 0)

		attrs = ut.formatAttrs(attrs)

		modules = []
		for mac in macs:
			id, pos_y, pos_x, mac_addr  = mac
			new_module = Module(self, attrs, id, mac_addr, pos_x, pos_y, self.fan_number, self.fan_layers)
			modules.append(new_module)

		return modules, attrs, macs
예제 #3
0
	def __init__(self, facility, name, conf_path):
		self.conf_path = conf_path
		self.facility = facility
		self.name = name

		# Is it easily doable without creating "fan_layout" ?
		self.fan_layout = ut.readConfig(self.conf_path, "DEFINE_FANS", 0)
		self.fan_number = int(self.fan_layout[0][0])
		self.fan_layers = int(self.fan_layout[0][1])

		# Flat list of Module objects, module_attrs is useful to be able to get the attributes even if no module is created
		self.modules_flat, self.module_attrs, self.module_macs = self.createModules()

		# 2D list of Module objects 
		nxs = [mod.pos_x for mod in self.modules_flat]
		nys = [mod.pos_y for mod in self.modules_flat]
		nx = max(nxs)-1
		ny = max(nys)-1

		self.modules = [[self.modules_flat[i+j*(nx+1)] for i in range(nx+1)] for j in range(ny+1)]


		self.modules_dict = self.createModulesDict()


		# 2D list that store FanUnits
		self.fan_units = self.arrangeFansInList2D()

		# Flat list that stores the Fan units
		self.fan_units_flat = [item for sublist in self.fan_units for item in sublist]

		# Set fan_units coordinate in meter - FanUnit.coords = (x, y) 
		self.setFansCoordinates()
예제 #4
0
    def createFanWalls(self):

        str_fan_walls = ut.readConfig(self.conf_path, "FAN_WALLS", 0)

        fan_walls = []
        for str_fan_wall in str_fan_walls:
            fan_walls.append(FanWall(self, str_fan_wall, self.conf_path))

        return fan_walls
예제 #5
0
    def createControlPanel(self):

        # List of list n x (atrs, mysqltype, python type)
        attrs = ut.readConfig(self.conf_path, "DEFINE_CONTROL_PANEL", 1)

        attrs = ut.formatAttrs(attrs)

        # List of [macAddr, ipAddr] for each control panel
        macs = ut.readConfig(self.conf_path, "CONTROL_PANEL_MAC", 0)

        if len(macs) > 0:
            mac = macs[0]
        else:
            mac = []

        if len(mac) == 2:
            control_panel = ControlPanel(self, attrs, mac[0], mac[1])
        else:
            control_panel = None

        return control_panel, attrs, mac
예제 #6
0
    def __init__(self, conf_path):
        self.conf_path = conf_path
        self.frequency = int(ut.readConfig(self.conf_path, "FREQ", 0)[0][0])

        self.ports = map(int, ut.readConfig(self.conf_path, "PORTS", 0)[0])
        self.db_access = ut.readConfig(self.conf_path, "DEFINE_DB", 0)[0]
        self.max_life_points = int(
            ut.readConfig(self.conf_path, "MAX_LIFE_POINTS", 0)[0][0])
        self.config_address = ut.readConfig(self.conf_path, "CONFIG_ADDRESS",
                                            0)[0][0]

        self.stop_flag = 0

        self.fan_walls = self.createFanWalls()
        self.sensors, self.sensor_attrs, self.sensor_macs = self.createSensors(
        )
        self.control_panel, self.control_panel_attrs, self.control_panel_mac = self.createControlPanel(
        )

        self.configuration = {}

        self.verbose = int(ut.readConfig(self.conf_path, "VERBOSE", 0)[0][0])
        self.module_verbose = int(
            ut.readConfig(self.conf_path, "MODULE_VERBOSE", 0)[0][0])

        # Rolling buffer for printing
        self.print_buff_size = 100
        self.print_buff = [''] * self.print_buff_size  # print buffer
        self.print_i = 0  # buffer iterator
        self.i_old = 0

        # Position of "client" in list "clients" is equal to "client_id"
        self.clients = [
        ]  # List of command clients (webapp, or any other sending on ports[5])

        self.control_token = 'free'  # can be "free", "emergency", "control_panel" or client_ip

        self.client_in_charge_name = ''  # Usefull only for client side

        # On server, updated by interpretMsgStatus. On client, updated by API or GUI.
        self.cmd_logging = False

        # On server, updated by logging thread, sent to client via getMsgStatus. On client, updated by interpretMsgStatus.
        self.state_logging = False
예제 #7
0
 def __init__(self):
     netData = readConfig(GO_CONFIG_PATH)[0]
     self.player = None
     self.connect_socket(netData)
     self.start_client()
예제 #8
0
 def __init__(self):
     #, gui=True,path=netData['default-player']
     netData = readConfig(GO_CONFIG_PATH)[0]
     self.player = PlayerFactory(remote=True).create()
     self.connect_socket(netData)
     self.start_client()
예제 #9
0
 def load_config(self):
     config = readConfig(PLAYER_CONFIG_PATH)
     self.depth = config[0]
예제 #10
0
 def __init__(self):
     netData = readConfig(GO_CONFIG_PATH)[0]
     self.player = PlayerFactory(remote=True).create()
     self.connect_socket(netData)
     self.start_client()