|
3 | 3 | from networkx.algorithms import components |
4 | 4 | from parchmint.layer import Layer |
5 | 5 | import networkx as nx |
6 | | -from typing import Dict, Optional, List |
| 6 | +from typing import Dict, Optional, List, overload |
7 | 7 | from parchmint.component import Component |
8 | 8 | from parchmint.connection import Connection |
9 | 9 | from parchmint.params import Params |
@@ -68,22 +68,53 @@ def __init__(self, json=None): |
68 | 68 | self.parse_from_json(json) |
69 | 69 | self.generate_network() |
70 | 70 |
|
71 | | - def map_valve(self, valve: Component, connection: Connection) -> None: |
| 71 | + def map_valve( |
| 72 | + self, |
| 73 | + valve: Component, |
| 74 | + connection: Connection, |
| 75 | + type_info: Optional[ValveType] = None, |
| 76 | + ) -> None: |
72 | 77 | """Maps the valve to a connection in the device |
73 | 78 |
|
74 | 79 | Args: |
75 | 80 | valve (Component): valve component |
76 | 81 | connection (Connection): connection on which the valve is mapped |
| 82 | + type_info (Optional[ValveType]): Type informaiton of the valve |
| 83 | +
|
77 | 84 | """ |
78 | 85 | self._valve_map[valve] = connection |
| 86 | + if type_info is not None: |
| 87 | + self.update_valve_type(valve, type_info) |
79 | 88 |
|
80 | 89 | def get_valves(self) -> List[Component]: |
| 90 | + """Returns the list of valves in the device |
| 91 | +
|
| 92 | + Returns: |
| 93 | + List[Component]: Valve Component Objects |
| 94 | + """ |
81 | 95 | return list(self._valve_map.keys()) |
82 | 96 |
|
83 | 97 | def get_valve_connection(self, valve: Component) -> Connection: |
| 98 | + """Returns the connection associated with the valve object |
| 99 | +
|
| 100 | + Args: |
| 101 | + valve (Component): Valve object for which we are finding the connection |
| 102 | +
|
| 103 | + Returns: |
| 104 | + Connection: connection object on which the valve is placed |
| 105 | + """ |
84 | 106 | return self._valve_map[valve] |
85 | 107 |
|
86 | 108 | def update_valve_type(self, valve: Component, type_info: ValveType) -> None: |
| 109 | + """Updates the type of the valve to normally closed or normally open |
| 110 | +
|
| 111 | + Args: |
| 112 | + valve (Component): Valve object we want to update |
| 113 | + type_info (ValveType): Valve Type |
| 114 | +
|
| 115 | + Raises: |
| 116 | + KeyError: Raises the error if the valve object is not mapped as a valve in the device |
| 117 | + """ |
87 | 118 | if valve in list(self._valve_map.keys()): |
88 | 119 | self._valve_type_map[valve] = type_info |
89 | 120 | else: |
|
0 commit comments