44# Author: Ian Patterson
55# Contact email: ian@botts-inc.com
66# ==============================================================================
7- import asyncio
8- import json
97
108from conSys4Py .core .default_api_helpers import APIHelper
11- from conSys4Py .datamodels .observations import ObservationOMJSONInline
129
1310from external_models import TimePeriod
1411from oshconnect import TemporalModes
@@ -50,12 +47,27 @@ def __init__(self, name: str, **kwargs):
5047 self ._datasource_handler .set_playback_mode (self ._playback_mode )
5148
5249 def get_name (self ):
50+ """
51+ Get the name of the OSHConnect instance.
52+ :return:
53+ """
5354 return self ._name
5455
5556 def add_node (self , node : Node ):
57+ """
58+ Add a node to the OSHConnect instance.
59+ :param node: Node object
60+ :return:
61+ """
5662 self ._nodes .append (node )
5763
5864 def remove_node (self , node_id : str ):
65+ """
66+ Remove a node from the OSHConnect instance.
67+ :param node_id:
68+ :return:
69+ """
70+ # TODO: should disconnect datastreams and delete them and all systems at the same time.
5971 # list of nodes in our node list that do not have the id of the node we want to remove
6072 self ._nodes = [node for node in self ._nodes if node .get_id () != node_id ]
6173
@@ -92,6 +104,12 @@ def select_temporal_mode(self, mode: str):
92104 pass
93105
94106 async def playback_streams (self , stream_ids : list = None ):
107+ """
108+ Begins playback of the datastreams that have been connected to the app. The method of playback is determined
109+ by the temporal mode that has been set.
110+ :param stream_ids:
111+ :return:
112+ """
95113 if stream_ids is None :
96114 await self ._datasource_handler .connect_all (self .timestream .get_time_range ())
97115 else :
@@ -106,6 +124,11 @@ def get_visualization_recommendations(self, streams: list):
106124 pass
107125
108126 def discover_datastreams (self ):
127+ """
128+ Discover datastreams of the current systems of the OSHConnect instance and create objects for them that are
129+ stored in the DataSourceHandler.
130+ :return:
131+ """
109132 # NOTE: This will need to check to prevent dupes in the future
110133 for system in self ._systems :
111134 res_datastreams = system .discover_datastreams ()
@@ -117,6 +140,12 @@ def discover_datastreams(self):
117140 list (map (self ._datasource_handler .add_datasource , new_datasource ))
118141
119142 def discover_systems (self , nodes : list [str ] = None ):
143+ """
144+ Discover systems from the nodes that have been added to the OSHConnect instance. They are associated with the
145+ nodes that they are discovered from so access to them flows through there.
146+ :param nodes:
147+ :return:
148+ """
120149 search_nodes = self ._nodes
121150 if nodes is not None :
122151 search_nodes = [node for node in search_nodes if node .get_id () in nodes ]
@@ -138,5 +167,12 @@ def set_playback_mode(self, mode: TemporalModes):
138167 self ._datasource_handler .set_playback_mode (mode )
139168
140169 def set_timeperiod (self , start_time : str , end_time : str ):
170+ """
171+ Sets the time range (TimePeriod) for the OSHConnect instance. This is used to bookend the playback of the
172+ datastreams.
173+ :param start_time: ISO8601 formatted string or one of (now or latest)
174+ :param end_time: ISO8601 formatted string or one of (now or latest)
175+ :return:
176+ """
141177 tp = TimePeriod (start = start_time , end = end_time )
142178 self .timestream = TimeManagement (time_range = tp )
0 commit comments