def __init__()

in lab/03-Package-Deploy/iot-jobs/app/turbine.py [0:0]


    def __init__(self, turbine_id=0, raw_data=None):
        if raw_data is None or len(raw_data) == 0:
            raise Exception("You need to pass an array with at least one row for raw data")

        self.turbine_id = turbine_id # id of the turbine
        self.raw_data = raw_data # buffer with the raw sensors data
        self.raw_data_idx = random.randint(0, len(raw_data)-1)
        
        self.running = False # running status
                
        self.halted = False # if True you can't use this turbine anymore. create a new one.

        # components of the UI
        self.stopped_img = open('../../../imgs/wind_turbine.png', 'rb').read()
        self.running_img = open('../../../imgs/wind_turbine.gif', 'rb').read()
        self.button = widgets.Button(description='Start (Id: %d)' % self.turbine_id)
        self.button.on_click(self.__on_button_clicked)
        
        self.img = widgets.Image(value=self.stopped_img,width=150, height=170)
        self.status_label = widgets.Label(
            layout={'width': "150px"}, value=''
        )

        self.vibration_status = widgets.Valid(value=False, description='Vibration')
        self.voltage_status = widgets.Valid(value=False, description='Voltage')
        self.rotation_status = widgets.Valid(value=False, description='Rotation')        
        
        self.noise_buttons = [    
            widgets.Button(description='Volt', layout={'width': '50px'}),
            widgets.Button(description='Rot', layout={'width': '50px'}),
            widgets.Button(description='Vib', layout={'width': '50px'})
        ]
        for i in self.noise_buttons: i.on_click(self.__on_noise_button_clicked)
        self.anomaly_status = widgets.VBox([
            self.vibration_status, self.voltage_status, self.rotation_status,
            widgets.Label("Inject noise"),
            widgets.HBox(self.noise_buttons)            
        ], layout={'visibility': 'hidden'})