functionalities
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,6 +1,5 @@
|
||||
from modele.exceptions import NonPolariseException, Dir
|
||||
|
||||
|
||||
class Composant(object):
|
||||
def __init__(self, conf, nom):
|
||||
"""
|
||||
@@ -38,6 +37,10 @@ class Composant(object):
|
||||
|
||||
def etat(self):
|
||||
raise NotImplementedError
|
||||
|
||||
def pause_simulation(self):
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class Contact(Composant):
|
||||
@@ -117,6 +120,8 @@ class Relais(Composant):
|
||||
self._contacts_repos = []
|
||||
self._contacts_double = []
|
||||
self.haut = False
|
||||
self.etat_precedent = False #etat precedent du relais
|
||||
self.est_point_arret = False #indicateur de point d'arret
|
||||
|
||||
def add_travail(self, nom):
|
||||
self._contacts_travail.append(nom)
|
||||
@@ -150,12 +155,16 @@ class Relais(Composant):
|
||||
self.graphe[nom].desactive()
|
||||
|
||||
def update(self):
|
||||
etat_precedent = self.haut
|
||||
super().update()
|
||||
if self.branche.i() >= self.SEUIL:
|
||||
self.monte()
|
||||
else:
|
||||
self.chute()
|
||||
|
||||
if self.est_point_arret and etat_precedent != self.haut:
|
||||
self.graphe.flag_arret_simulation = True
|
||||
|
||||
def etat(self):
|
||||
return self.haut
|
||||
|
||||
|
||||
@@ -13,7 +13,8 @@
|
||||
"RES_RELAIS": 100.0,
|
||||
"SEUIL_RELAIS": 0.05,
|
||||
"SEUIL_TEMPO": 0.05,
|
||||
"PULSE_PERIODE": 1.0
|
||||
"PULSE_PERIODE": 1.0,
|
||||
"TOLERANCE_COURANT": 1e6
|
||||
},
|
||||
"ui": {
|
||||
"DT": 0.13,
|
||||
|
||||
@@ -138,6 +138,26 @@ class Noeud(Element):
|
||||
|
||||
def etat(self):
|
||||
return self.u() >= self.conf['USEUIL']
|
||||
|
||||
|
||||
|
||||
def verifier_loi_des_noeuds(self):
|
||||
|
||||
"""Dans cette méthode, self._voisins contient les branches connectées au nœud, et polarite indique si le courant est entrant (-1) ou sortant (+1).
|
||||
La variable courant_total accumule la somme des courants, et self.conf['TOLERANCE_COURANT'] est une petite valeur seuil pour tolérer des imprécisions
|
||||
numériques (par exemple, 1e-6)."""
|
||||
|
||||
courant_total = 0
|
||||
for voisin, polarite, _ in self._voisins:
|
||||
if polarite == -1:
|
||||
courant_total -= voisin.i()
|
||||
else:
|
||||
courant_total += voisin.i()
|
||||
|
||||
if abs(courant_total) > self.conf['TOLERANCE_COURANT']:
|
||||
raise Exception(f"La loi des nœuds n'est pas respectée pour le noeud {self.nom}. Total courant: {courant_total}")
|
||||
|
||||
|
||||
|
||||
|
||||
class Branche(Element):
|
||||
|
||||
@@ -38,6 +38,7 @@ class Graphe(object):
|
||||
self.elements = None
|
||||
self.composants = None
|
||||
self.vecteur = None
|
||||
self.flag_arret_simulation = False
|
||||
|
||||
def load_data_from_schema_reader(self, reader):
|
||||
self.elements = {}
|
||||
@@ -168,4 +169,4 @@ class Graphe(object):
|
||||
[elt.update() for elt in self.elements.values()]
|
||||
|
||||
def coherence(self):
|
||||
[x.coherence() for x in self.elements.values()]
|
||||
[x.coherence() for x in self.elements.values()]
|
||||
Reference in New Issue
Block a user