This repository was archived by the owner on Feb 20, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmoteur.py
More file actions
54 lines (42 loc) · 1.54 KB
/
moteur.py
File metadata and controls
54 lines (42 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
from myThreads import Thread
import time
class Moteur(Thread):
"""Classe de base sur laquelle on construit les moteurs (classe fille)"""
count = 0
def __init__(self, run_event, newCoil_event, name=None):
Thread.__init__(self, name)
if name is None:
self.name = 'Moteur - {}'.format(Moteur.count)
else:
self.name = name
self.run_event = run_event
self.newCoil = newCoil_event
self.configurate = False
self.l.info('Instanciation de {}'.format(self.name))
def run(self):
while not self.stop: # Stop est dans le "myThreads"
while ((not self.newCoil.isSet()) and(not self.stop)):
self.newCoil.wait(1.0)
self.l.debug(('On attend les configurations'))
while ((not self.stop) and (not self.configurate)):
time.sleep(0.1)
self.configurate = self.config()
self.preBoucle()
while ((self.newCoil.isSet()) and(not self.stop)):
# On tourne dans la boucle
while ((not self.run_event.isSet()) and (not self.stop)):
self.pause()
self.boucle()
self.postBoucle()
def config(self):
return self.configurate
def preBoucle(self):
pass
def boucle(self):
pass
def pause(self):
time.sleep(0.1)
def postBoucle(self):
self.configurate = False