def __init__(self, data_path, params, search_params, threshold): # initialize helpers class self.FE = FeatureExtraction(params) self.Tr = Train(self.FE, data_path) self.SL = Slider(self.FE, search_params) self.Hr = Heater(threshold) # initialize the model and scaler self.clf, self.scaler = self.Tr.run()
def demoMode(): contractAddress0 = '0x2af54A206D2EaEa4ADDC5eE6489DfB3bdf072Cc5' contractAddress1 = '0xc7e08392aE35CD9903B2915c1C310B115AC3E548' contract0 = et.web3.eth.contract(address=contractAddress0, abi=et.readAbi("heater.json")) contract1 = et.web3.eth.contract(address=contractAddress1, abi=et.readAbi("heater.json")) heaters.append(Heater(contract0, '98:D3:C1:FD:85:30', 0, connectToSensor('98:D3:C1:FD:85:30', 1))) heaters.append(Heater(contract1, '98:D3:11:FC:5D:34', 1, connectToSensor('98:D3:11:FC:5D:34', 2))) initEvents() #demoMode()
def __init__(self, qToWorker, qFromWorker): multiprocessing.Process.__init__(self) self.qToWorker = qToWorker self.qFromWorker = qFromWorker self.setPointC = 0 self.hysteresis = 2 self.tempSensor1 = TCAmp(0) self.tempSensor2 = TCAmp(1) self.heater = Heater() self.ledWait = Output(18)
def testPool(): from heatLoss import Pool from geothermy import GeoSystem from heater import Heater bigPool = Pool(winterTemp=36, tempThreshold=20, insulationThickness=0.04) bigPool.standAlone = True bigPool.getTotalLoss() geoSystem = GeoSystem(bigPool, 1825, 1, 100, 2) geoSystem.tmiBlock = 275 geoSystem.numberOfWell = 30 geoSystem.wellDepth = 200 heater = Heater(geoSystem, waterExArea=43, numberOfYears=5) heater.standAlone = True heater.getQExchanger() bigPool.showPlot()
def testPool(): bigPool = Pool(winterTemp=36, tempThreshold=20, insulationThickness=0.04) bigPool.getTotalLoss() geoSystem = GeoSystem(bigPool, 1825, 1, 100, 2) geoSystem.tmiBlock = 275 geoSystem.numberOfWell = 30 geoSystem.wellDepth = 200 heater = Heater(geoSystem, waterExArea=43, numberOfYears=5) heater.getQExchanger() geoSystem.graphTmoTmiAtAllTime() geoSystem.graphQSystems() geoSystem.graphSuperpositionNodes() geoSystem.graphWPACAllTime() geoSystem.graphSuperpositionProfiles()
def __parse_components(self, components): for component in components: entity = Component() if component['type'] == 'heating': entity = Heater(component['id'], component['is_on'], component['min'], component['max'], component['now']) HeaterWrapper().tie(entity) entity.start(1.0) elif component['type'] == 'light_bulb': entity = LightBulb(component['id'], component['is_on']) elif component['type'] == 'light_bulb_brightness': entity = LightBulbBrightness(component['id'], component['is_on'], component['now']) self.components.append(entity)
def test_pool_utils(self): # On créé le mock mock = MagicMock() # On set les valeurs de retour attendues mock.get_actual_temp.return_value = 20 mock.get_last_days_temps.return_value = [20, 21, 20, 19, 24, 20, 20] mock.set_heater.return_value = False # On instancie le heater heater = Heater(functions=mock) # On lance les tests self.assertEqual(20, heater.pool_utils.get_actual_temp()) self.assertEqual([20, 21, 20, 19, 24, 20, 20], heater.pool_utils.get_last_days_temps()) self.assertEqual(False, heater.pool_utils.set_heater())
def analyzeMessage(data, sock): data = data.decode("utf-8") if(data == "getdevices"): sendMessageTo(sock, lookUpNearbyBluetoothDevices()) elif(data == "ready"): readySensors(sock) else: subdata = data.split("#") if(subdata[0] == "adds"): #deploy heater macAddress = subdata[1].split("&")[0] thermostatAddress = subdata[1].split("@")[1] contractAddress = et.deployNewHeater(thermostatAddress) sendMessageTo(sock, "ok#" + macAddress + "&" + contractAddress) index = len(sensors) contracth = et.web3.eth.contract(address=contractAddress, abi=et.readAbi("sensor.json")) addHeater(Heater(contracth, macAddress, index, connectToSensor(macAddress, index + 1))) print("Serial port with sensor " + macAddress + " opened!")
class videoPipeline(): def __init__(self, data_path, params, search_params, threshold): # initialize helpers class self.FE = FeatureExtraction(params) self.Tr = Train(self.FE, data_path) self.SL = Slider(self.FE, search_params) self.Hr = Heater(threshold) # initialize the model and scaler self.clf, self.scaler = self.Tr.run() def process_image(self, img, draw=True): current_windows = self.SL.run_efficient(img, self.clf, self.scaler) draw_img, heatmap = self.Hr.run(img, current_windows) result = draw_img if draw else heatmap return draw_img def run(self, input_video, output_video): print('Starting video processing...') raw_clip = VideoFileClip(input_video) processed_clip = raw_clip.fl_image(self.process_image) processed_clip.write_videofile(output_video, audio=False) print('End of video processing...')
def wash_main(): heater = Heater() motor = Motor() sensor = Sensor() stain_removal = StainRemoval() wash_button = WashButton() wash_machine = WashMachine() valve = Valve() def wash_cycle(mediator): wash_machine.set_mediator(mediator) wash_button.set_mediator(mediator) heater.set_mediator(mediator) valve.set_mediator(mediator) wash_button.press() mediator = ColorsMediator( heater, wash_machine, motor, stain_removal, sensor, valve, ) wash_cycle(mediator) print("\n") mediator = WhitesMediator( heater, wash_machine, motor, stain_removal, sensor, valve, ) wash_cycle(mediator)
#!bin/python3 from flask import Flask, request, render_template from twilio.twiml.messaging_response import MessagingResponse import RPi.GPIO as GPIO from heater import Heater # create heater object heater = Heater() # ON and OFF phrase that we want to match with recieved SMS on_phrase = ['on', 'heater on', 'turn heater on', 'turn on'] off_phrase = ['off', 'heater off', 'turn heater off', 'turn off'] app = Flask(__name__) @app.route('/') def home(): led_status = heater.get_status() return render_template('home.html', led_status=led_status) @app.route('/led/<int:led_state>', methods=['POST']) def led(led_state): if led_state == 1: heater.set_led(True) elif led_state == 0: heater.set_led(False) else: return ('Bad request', 400)
window = MainWindow() processor = ImageProcessor() statsComputer = StatsComputer() tracker = CentroidTracker() # Instantiate objects if is_raspberry_pi(): vs = PiVideoStream(resolution=(WIDTH, HEIGHT), monochrome=True, framerate=FRAME_RATE, effect='blur', use_video_port=USE_VIDEO_PORT) pio = pigpio.pi() vc = VoiceCoil(pio) af = None heater = Heater(pio, 2000) else: filename, _ = QFileDialog.getOpenFileName(caption='Open file', dir='.', filter='*.mp4') print(filename) vs = VideoStream(filename, resolution=(WIDTH, HEIGHT), monochrome=True) # Start video stream vs.start(QThread.HighPriority) processor.start(QThread.HighPriority) tracker.start(QThread.HighPriority) # Connect video/image stream to processing (Qt.BlockingQueuedConnection or QueuedConnection?) vs.signals.result.connect(processor.update, type=Qt.BlockingQueuedConnection) processor.signals.result.connect(statsComputer.start)
from motor import StepperMotor from motor import GearBoxMotor from heater import Heater from contact_switch import ContactSwitch import pigpio import time linear_push = StepperMotor(13, 06, ENABLE_PIN=17) # green and orange wires mm_rotate_motor = GearBoxMotor(23) # blue single wire cracker_motor = StepperMotor(26, 19, ENABLE_PIN=27) # gray and blue wires chocolate_motor = StepperMotor(16, 12, ENABLE_PIN=3) # red and gray wire rotate_base_motor = StepperMotor(5, 11, ENABLE_PIN=2) # purple and green h1 = Heater(7) # bright yellow wire with some green pi = pigpio.pi() c1 = ContactSwitch(20) def stop_all(): linear_push.stop() cracker_motor.stop() mm_rotate_motor.stop() chocolate_motor.stop() rotate_base_motor.stop() h1.stop() pigpio.stop() def test_linear(motor=chocolate_motor):
class BoilerWorker(multiprocessing.Process): def __init__(self, qToWorker, qFromWorker): multiprocessing.Process.__init__(self) self.qToWorker = qToWorker self.qFromWorker = qFromWorker self.setPointC = 0 self.hysteresis = 2 self.tempSensor1 = TCAmp(0) self.tempSensor2 = TCAmp(1) self.heater = Heater() self.ledWait = Output(18) def run(self): signal.signal(signal.SIGINT, signal.SIG_IGN) try: while True: self.controlHeater() try: message = self.qToWorker.get(block=True, timeout=0.01) except queue.Empty: continue if message.command == 'shutdown': break elif message.command == 'setTemperatureC': self.setTemperatureC(message.data) elif message.command == 'getTemperatures': self.qFromWorker.put( Message('temperatures', [ self.tempSensor1.getTemperatureC(), self.tempSensor2.getTemperatureC() ])) else: raise ValueError('no command: {}'.format(message)) finally: self.shutdownHeater() def controlHeater(self): temperature1 = self.tempSensor1.getTemperatureC() temperature2 = self.tempSensor2.getTemperatureC() maxDelta = 5 if abs(temperature1 - temperature2) > maxDelta: raise RuntimeError( 'temperatures differ more than {}\n'.format(maxDelta) + 'temp1: {}, temp2: {}'.format(temperature1, temperature2)) temperature = (temperature1 + temperature2) / 2 if ((not self.heater.isOn()) and (temperature < self.setPointC - self.hysteresis)): self.heater.turnOn() self.turnLedWaitOn() if ((self.heater.isOn()) and (temperature > self.setPointC + self.hysteresis)): self.heater.turnOff() self.turnLedWaitOff() self.heater.resetWatchdog() def shutdownHeater(self): self.heater.turnOff() self.turnLedWaitOff() def setTemperatureC(self, temperatureC): self.setPointC = temperatureC def turnLedWaitOn(self): self.ledWait.set() def turnLedWaitOff(self): self.ledWait.clear()
from TV import TV from heater import Heater from oven import Oven class Kitchen(): def __init__(self, size): self.size = size self.tv = None self.heater = None self.oven = None jakub_tv = TV(40, 50, True) jakub_heater = Heater("small", "1.6kw") jakub_oven = Oven(150, 200, 56, "electronic", "black") jakub_kitchen = Kitchen("large") jakub_kitchen.tv = jakub_tv jakub_kitchen.heater = jakub_heater print(jakub_kitchen.tv) print(jakub_heater) print(jakub_oven)
from tank import Tank from pump import Pump from valve import Valve from stirrer import Stirrer from heater import Heater import time tanks = [Tank(500, False, False, Valve(10, 2)), # coffee Tank(1000, False, Heater(300), False), # water Tank(1000, Stirrer(10), False, Valve(50, 4)), # main tank Tank(1000, False, False, False), # milk Tank(500, False, False, False)] # cup pumps = [Pump(30, [1, 2]), # water -> main tank Pump(20, [3, 2])] # milk -> main tank flag = 0 dTime = time.time() dTimeWater = time.time() while True: # main loop if time.time() - dTime > 0.1: # 10Hz if flag == 0: # Question about amount of coffee try: amount = int(input("Write how much coffee do you want(ml)")) except ValueError: print("Not an number!") continue else: if amount > 500: print("This is too much, choose amount up to 500ml")
tower = Tower(car_x=start_car_pos[0], car_y=start_car_pos[1], car_z=start_car_pos[2], car_e=start_car_pos[3], step_length=2, std_v=standart_v) # with Connection(MEGA) as mega, \ # Connection(UNO) as uno: with Connection(MEGA) as mega: """ блок инициализации объектов """ # navi = Navigation(uno, TAG_PORT) touch_probe = TouchProbe(mega, tower) heater = Heater(mega) table = TableCalibrate(mega, tower, touch_probe) edge_search = EdgeSearch(mega, tower, table) time.sleep(2) print('start') if (is_interactive): run_tests(mega, num_tests=1000) else: # list_of_files = ['1st_move.gcode', '2nd_move.txt'] # for file_name in list_of_files: for i in range(1): file_name = 'aramka200x100.gcode' with open(file_name) as gcode: for line in gcode:
from motor import StepperMotor from motor import GearBoxMotor from heater import Heater from contact_switch import ContactSwitch import pigpio import time # pi = pigpio.pi() linear_push = StepperMotor(13, 06, ENABLE_PIN=17) # green and orange wires mm_rotate_motor = GearBoxMotor(23) # blue single wire cracker_motor = StepperMotor(26, 19, ENABLE_PIN=27) # gray and blue wires chocolate_motor = StepperMotor(16, 12, ENABLE_PIN=3) # red and gray wire rotate_base_motor = StepperMotor(5, 11, ENABLE_PIN=2) # purple and green h1 = Heater(7) # bright yellow wire with some green c1 = ContactSwitch(20) def stop_all(): linear_push.stop() cracker_motor.stop() mm_rotate_motor.stop() chocolate_motor.stop() rotate_base_motor.stop() h1.stop() pigpio.stop() rot = 1.62 try:
from dht11 import DHT11 from heater import Heater from loramessage import LoRaMessage from time import sleep dht11 = DHT11() message = LoRaMessage() heater = Heater() temp_threshold = 25 max_cycles = 2 num_cycles = 0 a = 100 #while True: while a > 0: message.send_message("heater_enabled: True") print("heater_enabled: True") #temperature = dht11.get_temperature() temperature = dht11.get_sim_temperature(temp_threshold) if (temperature < temp_threshold): num_cycles += 1 heater.on() else: heater.off() if (num_cycles >= max_cycles): heater.off() num_cycles = 0 message.send_message("heater_enabled: False") print("heater_enabled: False") sleep(5)