ansys-systemcoupling-core 0.4.1__py3-none-any.whl → 0.6__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of ansys-systemcoupling-core might be problematic. Click here for more details.
- ansys/systemcoupling/core/__init__.py +11 -5
- ansys/systemcoupling/core/adaptor/api_23_1/_clear_state.py +13 -0
- ansys/systemcoupling/core/adaptor/api_23_1/case_root.py +7 -1
- ansys/systemcoupling/core/adaptor/api_23_1/clear_state.py +4 -2
- ansys/systemcoupling/core/adaptor/api_23_1/show_plot.py +75 -0
- ansys/systemcoupling/core/adaptor/api_23_1/solution_root.py +7 -1
- ansys/systemcoupling/core/adaptor/api_23_2/_clear_state.py +13 -0
- ansys/systemcoupling/core/adaptor/api_23_2/case_root.py +7 -1
- ansys/systemcoupling/core/adaptor/api_23_2/clear_state.py +4 -2
- ansys/systemcoupling/core/adaptor/api_23_2/show_plot.py +75 -0
- ansys/systemcoupling/core/adaptor/api_23_2/solution_root.py +7 -1
- ansys/systemcoupling/core/adaptor/api_24_1/_clear_state.py +13 -0
- ansys/systemcoupling/core/adaptor/api_24_1/case_root.py +7 -1
- ansys/systemcoupling/core/adaptor/api_24_1/clear_state.py +4 -2
- ansys/systemcoupling/core/adaptor/api_24_1/show_plot.py +75 -0
- ansys/systemcoupling/core/adaptor/api_24_1/solution_root.py +7 -1
- ansys/systemcoupling/core/adaptor/api_24_2/_add_participant.py +80 -0
- ansys/systemcoupling/core/adaptor/api_24_2/_clear_state.py +13 -0
- ansys/systemcoupling/core/adaptor/api_24_2/_solve.py +13 -0
- ansys/systemcoupling/core/adaptor/api_24_2/abort.py +39 -0
- ansys/systemcoupling/core/adaptor/api_24_2/activate_hidden.py +46 -0
- ansys/systemcoupling/core/adaptor/api_24_2/add_aerodamping_data_transfers.py +43 -0
- ansys/systemcoupling/core/adaptor/api_24_2/add_data_transfer.py +190 -0
- ansys/systemcoupling/core/adaptor/api_24_2/add_data_transfer_by_display_names.py +191 -0
- ansys/systemcoupling/core/adaptor/api_24_2/add_expression_function.py +61 -0
- ansys/systemcoupling/core/adaptor/api_24_2/add_fsi_data_transfers.py +43 -0
- ansys/systemcoupling/core/adaptor/api_24_2/add_interface.py +77 -0
- ansys/systemcoupling/core/adaptor/api_24_2/add_interface_by_display_names.py +78 -0
- ansys/systemcoupling/core/adaptor/api_24_2/add_named_expression.py +42 -0
- ansys/systemcoupling/core/adaptor/api_24_2/add_ordered_data_transfers.py +32 -0
- ansys/systemcoupling/core/adaptor/api_24_2/add_participant.py +162 -0
- ansys/systemcoupling/core/adaptor/api_24_2/add_reference_frame.py +40 -0
- ansys/systemcoupling/core/adaptor/api_24_2/add_thermal_data_transfers.py +43 -0
- ansys/systemcoupling/core/adaptor/api_24_2/add_transformation.py +102 -0
- ansys/systemcoupling/core/adaptor/api_24_2/analysis_control.py +283 -0
- ansys/systemcoupling/core/adaptor/api_24_2/apip.py +33 -0
- ansys/systemcoupling/core/adaptor/api_24_2/ascii_output.py +44 -0
- ansys/systemcoupling/core/adaptor/api_24_2/attribute.py +20 -0
- ansys/systemcoupling/core/adaptor/api_24_2/attribute_child.py +54 -0
- ansys/systemcoupling/core/adaptor/api_24_2/automatic_alignment_options.py +46 -0
- ansys/systemcoupling/core/adaptor/api_24_2/available_ports.py +40 -0
- ansys/systemcoupling/core/adaptor/api_24_2/avoid_data_reconstruction.py +46 -0
- ansys/systemcoupling/core/adaptor/api_24_2/case_root.py +62 -0
- ansys/systemcoupling/core/adaptor/api_24_2/clear_state.py +18 -0
- ansys/systemcoupling/core/adaptor/api_24_2/connect_ensight_dvs.py +41 -0
- ansys/systemcoupling/core/adaptor/api_24_2/coupling_interface.py +20 -0
- ansys/systemcoupling/core/adaptor/api_24_2/coupling_interface_child.py +42 -0
- ansys/systemcoupling/core/adaptor/api_24_2/coupling_participant.py +23 -0
- ansys/systemcoupling/core/adaptor/api_24_2/coupling_participant_child.py +265 -0
- ansys/systemcoupling/core/adaptor/api_24_2/create_restart_point.py +29 -0
- ansys/systemcoupling/core/adaptor/api_24_2/data_transfer.py +20 -0
- ansys/systemcoupling/core/adaptor/api_24_2/data_transfer_child.py +187 -0
- ansys/systemcoupling/core/adaptor/api_24_2/delete_snapshot.py +28 -0
- ansys/systemcoupling/core/adaptor/api_24_2/delete_transformation.py +42 -0
- ansys/systemcoupling/core/adaptor/api_24_2/dimensionality.py +96 -0
- ansys/systemcoupling/core/adaptor/api_24_2/execution_control.py +246 -0
- ansys/systemcoupling/core/adaptor/api_24_2/execution_control_1.py +24 -0
- ansys/systemcoupling/core/adaptor/api_24_2/expression.py +20 -0
- ansys/systemcoupling/core/adaptor/api_24_2/expression_child.py +36 -0
- ansys/systemcoupling/core/adaptor/api_24_2/expression_function.py +20 -0
- ansys/systemcoupling/core/adaptor/api_24_2/expression_function_child.py +46 -0
- ansys/systemcoupling/core/adaptor/api_24_2/external_data_file.py +24 -0
- ansys/systemcoupling/core/adaptor/api_24_2/fluent_input.py +77 -0
- ansys/systemcoupling/core/adaptor/api_24_2/fmu_parameter.py +20 -0
- ansys/systemcoupling/core/adaptor/api_24_2/fmu_parameter_child.py +156 -0
- ansys/systemcoupling/core/adaptor/api_24_2/generate_input_file.py +41 -0
- ansys/systemcoupling/core/adaptor/api_24_2/get_add_data_transfer_group_commands.py +29 -0
- ansys/systemcoupling/core/adaptor/api_24_2/get_execution_command.py +30 -0
- ansys/systemcoupling/core/adaptor/api_24_2/get_machines.py +13 -0
- ansys/systemcoupling/core/adaptor/api_24_2/get_mode_shape_variables.py +29 -0
- ansys/systemcoupling/core/adaptor/api_24_2/get_region_names_for_participant.py +31 -0
- ansys/systemcoupling/core/adaptor/api_24_2/get_setup_summary.py +25 -0
- ansys/systemcoupling/core/adaptor/api_24_2/get_status_messages.py +52 -0
- ansys/systemcoupling/core/adaptor/api_24_2/get_supported_participant_types.py +13 -0
- ansys/systemcoupling/core/adaptor/api_24_2/get_thermal_data_transfer_options.py +32 -0
- ansys/systemcoupling/core/adaptor/api_24_2/get_transformation.py +43 -0
- ansys/systemcoupling/core/adaptor/api_24_2/global_stabilization.py +143 -0
- ansys/systemcoupling/core/adaptor/api_24_2/has_input_file_changed.py +36 -0
- ansys/systemcoupling/core/adaptor/api_24_2/import_system_coupling_input_file.py +36 -0
- ansys/systemcoupling/core/adaptor/api_24_2/initialize.py +27 -0
- ansys/systemcoupling/core/adaptor/api_24_2/instancing.py +23 -0
- ansys/systemcoupling/core/adaptor/api_24_2/instancing_child.py +62 -0
- ansys/systemcoupling/core/adaptor/api_24_2/interrupt.py +39 -0
- ansys/systemcoupling/core/adaptor/api_24_2/library.py +37 -0
- ansys/systemcoupling/core/adaptor/api_24_2/live_visualization.py +20 -0
- ansys/systemcoupling/core/adaptor/api_24_2/live_visualization_child.py +100 -0
- ansys/systemcoupling/core/adaptor/api_24_2/mapping_control.py +239 -0
- ansys/systemcoupling/core/adaptor/api_24_2/open.py +102 -0
- ansys/systemcoupling/core/adaptor/api_24_2/open_results_in_ensight.py +56 -0
- ansys/systemcoupling/core/adaptor/api_24_2/open_snapshot.py +37 -0
- ansys/systemcoupling/core/adaptor/api_24_2/output_control.py +134 -0
- ansys/systemcoupling/core/adaptor/api_24_2/parameter.py +20 -0
- ansys/systemcoupling/core/adaptor/api_24_2/parameter_child.py +56 -0
- ansys/systemcoupling/core/adaptor/api_24_2/partition_participants.py +138 -0
- ansys/systemcoupling/core/adaptor/api_24_2/properties.py +36 -0
- ansys/systemcoupling/core/adaptor/api_24_2/record_interactions.py +46 -0
- ansys/systemcoupling/core/adaptor/api_24_2/reference_frame.py +20 -0
- ansys/systemcoupling/core/adaptor/api_24_2/reference_frame_child.py +71 -0
- ansys/systemcoupling/core/adaptor/api_24_2/region.py +20 -0
- ansys/systemcoupling/core/adaptor/api_24_2/region_child.py +71 -0
- ansys/systemcoupling/core/adaptor/api_24_2/reload_expression_function_modules.py +14 -0
- ansys/systemcoupling/core/adaptor/api_24_2/results.py +89 -0
- ansys/systemcoupling/core/adaptor/api_24_2/save.py +51 -0
- ansys/systemcoupling/core/adaptor/api_24_2/save_snapshot.py +54 -0
- ansys/systemcoupling/core/adaptor/api_24_2/setup_root.py +251 -0
- ansys/systemcoupling/core/adaptor/api_24_2/show_plot.py +75 -0
- ansys/systemcoupling/core/adaptor/api_24_2/shutdown.py +25 -0
- ansys/systemcoupling/core/adaptor/api_24_2/side.py +20 -0
- ansys/systemcoupling/core/adaptor/api_24_2/side_child.py +56 -0
- ansys/systemcoupling/core/adaptor/api_24_2/solution_control.py +115 -0
- ansys/systemcoupling/core/adaptor/api_24_2/solution_root.py +122 -0
- ansys/systemcoupling/core/adaptor/api_24_2/solve.py +30 -0
- ansys/systemcoupling/core/adaptor/api_24_2/stabilization.py +157 -0
- ansys/systemcoupling/core/adaptor/api_24_2/start_participants.py +47 -0
- ansys/systemcoupling/core/adaptor/api_24_2/step.py +57 -0
- ansys/systemcoupling/core/adaptor/api_24_2/transformation.py +21 -0
- ansys/systemcoupling/core/adaptor/api_24_2/transformation_child.py +62 -0
- ansys/systemcoupling/core/adaptor/api_24_2/type.py +38 -0
- ansys/systemcoupling/core/adaptor/api_24_2/unmapped_value_options.py +158 -0
- ansys/systemcoupling/core/adaptor/api_24_2/update_control.py +43 -0
- ansys/systemcoupling/core/adaptor/api_24_2/update_participant.py +61 -0
- ansys/systemcoupling/core/adaptor/api_24_2/variable.py +20 -0
- ansys/systemcoupling/core/adaptor/api_24_2/variable_child.py +231 -0
- ansys/systemcoupling/core/adaptor/api_24_2/write_csv_chart_files.py +21 -0
- ansys/systemcoupling/core/adaptor/api_24_2/write_ensight.py +46 -0
- ansys/systemcoupling/core/adaptor/impl/injected_commands.py +228 -27
- ansys/systemcoupling/core/adaptor/impl/static_info.py +17 -0
- ansys/systemcoupling/core/adaptor/impl/syc_proxy.py +3 -0
- ansys/systemcoupling/core/adaptor/impl/syc_proxy_interface.py +4 -0
- ansys/systemcoupling/core/adaptor/impl/types.py +1 -1
- ansys/systemcoupling/core/charts/chart_datatypes.py +169 -0
- ansys/systemcoupling/core/charts/csv_chartdata.py +299 -0
- ansys/systemcoupling/core/charts/live_csv_datasource.py +87 -0
- ansys/systemcoupling/core/charts/message_dispatcher.py +84 -0
- ansys/systemcoupling/core/charts/plot_functions.py +92 -0
- ansys/systemcoupling/core/charts/plotdefinition_manager.py +303 -0
- ansys/systemcoupling/core/charts/plotter.py +343 -0
- ansys/systemcoupling/core/client/grpc_client.py +6 -1
- ansys/systemcoupling/core/participant/manager.py +25 -9
- ansys/systemcoupling/core/participant/protocol.py +1 -0
- ansys/systemcoupling/core/session.py +4 -4
- ansys/systemcoupling/core/syc_version.py +1 -1
- ansys/systemcoupling/core/util/file_transfer.py +4 -0
- ansys/systemcoupling/core/util/logging.py +1 -1
- {ansys_systemcoupling_core-0.4.1.dist-info → ansys_systemcoupling_core-0.6.dist-info}/METADATA +17 -16
- {ansys_systemcoupling_core-0.4.1.dist-info → ansys_systemcoupling_core-0.6.dist-info}/RECORD +148 -26
- {ansys_systemcoupling_core-0.4.1.dist-info → ansys_systemcoupling_core-0.6.dist-info}/LICENSE +0 -0
- {ansys_systemcoupling_core-0.4.1.dist-info → ansys_systemcoupling_core-0.6.dist-info}/WHEEL +0 -0
|
@@ -241,7 +241,7 @@ class SettingsBase(Base, Generic[StateT]):
|
|
|
241
241
|
|
|
242
242
|
def get_property_state(self, prop):
|
|
243
243
|
"""Get the state of the ``prop`` property ."""
|
|
244
|
-
return self.sycproxy.
|
|
244
|
+
return self.sycproxy.get_property_state(self.syc_path, self.to_syc_name(prop))
|
|
245
245
|
|
|
246
246
|
@staticmethod
|
|
247
247
|
def _print_state_helper(state, out, indent=0, indent_factor=2):
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
# Copyright (C) 2023 - 2024 ANSYS, Inc. and/or its affiliates.
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
#
|
|
4
|
+
#
|
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
# furnished to do so, subject to the following conditions:
|
|
11
|
+
#
|
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
# copies or substantial portions of the Software.
|
|
14
|
+
#
|
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
# SOFTWARE.
|
|
22
|
+
|
|
23
|
+
from dataclasses import dataclass, field
|
|
24
|
+
from enum import Enum
|
|
25
|
+
from typing import Optional
|
|
26
|
+
|
|
27
|
+
"""Common data types for the storage of metadata and data for chart series.
|
|
28
|
+
|
|
29
|
+
All series are assumed to belong to an interface and to a data transfer within the interface
|
|
30
|
+
|
|
31
|
+
Raw data should be processed into this format from whatever source is available (CSV file
|
|
32
|
+
or streamed data, for example) and the actual charts will be built from this.
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class SeriesType(Enum):
|
|
37
|
+
CONVERGENCE = 1
|
|
38
|
+
SUM = 2
|
|
39
|
+
WEIGHTED_AVERAGE = 3
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
@dataclass
|
|
43
|
+
class TransferSeriesInfo:
|
|
44
|
+
"""Information about the chart series data associated with a data transfer.
|
|
45
|
+
|
|
46
|
+
Attributes
|
|
47
|
+
----------
|
|
48
|
+
data_index : int
|
|
49
|
+
This is used by the data source processor to associate this information (likely
|
|
50
|
+
obtained from heading or other metadata) with the correct data series.
|
|
51
|
+
It indexes into the full list of series associated with a given interface.
|
|
52
|
+
series_type : SeriesType
|
|
53
|
+
The type of line series.
|
|
54
|
+
transfer_display_name : str
|
|
55
|
+
The display name of the data transfer. This is a primary identifier for data
|
|
56
|
+
transfers because CSV data sources do not currently include information about
|
|
57
|
+
the underlying data model names of data transfers.
|
|
58
|
+
disambiguation_index: int
|
|
59
|
+
This should be set to 0, unless there is more than one data transfer with the
|
|
60
|
+
same display name. A contiguous range of indexes starting at 0 should be assigned
|
|
61
|
+
to the list of data transfers with the same display name.
|
|
62
|
+
participant_display_name : str, optional
|
|
63
|
+
The display name of the participant. This is required for transfer value series
|
|
64
|
+
but not for convergence series.
|
|
65
|
+
line_suffixes: list[str]
|
|
66
|
+
This should always be empty for convergence series. For transfer value series,
|
|
67
|
+
it should contain the suffixes for any component series that exist. That is,
|
|
68
|
+
suffixes for complex components, "real" or "imag", and suffixes for vector
|
|
69
|
+
components, "x", "y", "z", or a combination of complex and vector component
|
|
70
|
+
types. The data indexes for individual components of the transfer are assumed
|
|
71
|
+
to be contiguous from ``data_index``.
|
|
72
|
+
"""
|
|
73
|
+
|
|
74
|
+
data_index: int
|
|
75
|
+
series_type: SeriesType
|
|
76
|
+
transfer_display_name: str
|
|
77
|
+
disambiguation_index: int
|
|
78
|
+
# Remainder for non-CONVERGENCE series only
|
|
79
|
+
participant_display_name: Optional[str] = None
|
|
80
|
+
line_suffixes: list[str] = field(default_factory=list)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
@dataclass
|
|
84
|
+
class InterfaceInfo:
|
|
85
|
+
"""Information about the chart series data associated with a single interface.
|
|
86
|
+
|
|
87
|
+
Attributes
|
|
88
|
+
----------
|
|
89
|
+
name : str
|
|
90
|
+
The name of the coupling interface data model object.
|
|
91
|
+
display_name : str, optional
|
|
92
|
+
The display name of the interface object. This may be unassigned initially.
|
|
93
|
+
is_transient : bool
|
|
94
|
+
Whether the data on this interface is associated with a transient analysis.
|
|
95
|
+
transfer_info : list[TransferSeriesInfo]
|
|
96
|
+
The list of ``TransferSeriesInfo`` associated with this interface.
|
|
97
|
+
"""
|
|
98
|
+
|
|
99
|
+
name: str
|
|
100
|
+
display_name: str = "" # TODO: check whether this is actually needed.
|
|
101
|
+
is_transient: bool = False
|
|
102
|
+
transfer_info: list[TransferSeriesInfo] = field(default_factory=list)
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
@dataclass
|
|
106
|
+
class SeriesData:
|
|
107
|
+
"""The plot data for a single chart line series and information to allow
|
|
108
|
+
it to be associated with chart metadata.
|
|
109
|
+
|
|
110
|
+
An instance of this type is assumed to be associated externally with a
|
|
111
|
+
single interface.
|
|
112
|
+
|
|
113
|
+
Attributes
|
|
114
|
+
----------
|
|
115
|
+
transfer_index : int
|
|
116
|
+
Index of the ``TransferSeriesInfo`` metadata for this series within the
|
|
117
|
+
``InterfaceInfo`` for the interface this series is associated with.
|
|
118
|
+
component_index : int, optional
|
|
119
|
+
The component index if this series is one of a set of complex and/or
|
|
120
|
+
vector components of the transfer. Otherwise is ``None``.
|
|
121
|
+
start_index : int, optional
|
|
122
|
+
The starting iteration of the ``data`` field. This defaults to 0 and
|
|
123
|
+
only needs to be set to a different value if incremental data, such
|
|
124
|
+
as might arise during "live" update of plots, has become available.
|
|
125
|
+
data : list[float]
|
|
126
|
+
The series data. This is always indexed by iteration. Extract time
|
|
127
|
+
step-based data by using a time step to iteration mapping.
|
|
128
|
+
"""
|
|
129
|
+
|
|
130
|
+
transfer_index: int # Index into transfer_info of associated InterfaceInfo
|
|
131
|
+
component_index: Optional[int] = None # Component index if applicable
|
|
132
|
+
|
|
133
|
+
start_index: int = 0 # Use when providing incremental data
|
|
134
|
+
|
|
135
|
+
data: list[float] = field(default_factory=list)
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
@dataclass
|
|
139
|
+
class InterfaceSeriesData:
|
|
140
|
+
"""The series data for given interface.
|
|
141
|
+
|
|
142
|
+
Attributes
|
|
143
|
+
----------
|
|
144
|
+
info : InterfaceInfo
|
|
145
|
+
The metadata for the interface.
|
|
146
|
+
series : list[SeriesData]
|
|
147
|
+
The data for all series associated with the interface.
|
|
148
|
+
"""
|
|
149
|
+
|
|
150
|
+
info: InterfaceInfo
|
|
151
|
+
series: list[SeriesData] = field(default_factory=list)
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
@dataclass
|
|
155
|
+
class TimestepData:
|
|
156
|
+
"""Mappings from iteration to time step and time.
|
|
157
|
+
|
|
158
|
+
Attributes
|
|
159
|
+
----------
|
|
160
|
+
timestep : list[int]
|
|
161
|
+
Timestep indexes, indexed by iteration. Typically, multiple consecutive
|
|
162
|
+
iteration indexes map to the same timestep index.
|
|
163
|
+
time: list[float]
|
|
164
|
+
Time values, indexed by iteration. Typically, multiple consecutive iteration
|
|
165
|
+
indexes map to the same time value.
|
|
166
|
+
"""
|
|
167
|
+
|
|
168
|
+
timestep: list[int] = field(default_factory=list) # iter -> step index
|
|
169
|
+
time: list[float] = field(default_factory=list) # iter -> time
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
# Copyright (C) 2023 - 2024 ANSYS, Inc. and/or its affiliates.
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
#
|
|
4
|
+
#
|
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
# furnished to do so, subject to the following conditions:
|
|
11
|
+
#
|
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
# copies or substantial portions of the Software.
|
|
14
|
+
#
|
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
# SOFTWARE.
|
|
22
|
+
|
|
23
|
+
# from dataclasses import dataclass, field
|
|
24
|
+
import csv
|
|
25
|
+
from typing import TextIO, Union
|
|
26
|
+
|
|
27
|
+
from ansys.systemcoupling.core.charts.chart_datatypes import (
|
|
28
|
+
InterfaceInfo,
|
|
29
|
+
InterfaceSeriesData,
|
|
30
|
+
SeriesData,
|
|
31
|
+
SeriesType,
|
|
32
|
+
TimestepData,
|
|
33
|
+
TransferSeriesInfo,
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
HeaderList = list[str]
|
|
37
|
+
ChartData = list[list[float]]
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class CsvReader:
|
|
41
|
+
def __init__(self, file_or_filename: Union[str, TextIO]):
|
|
42
|
+
self._file_or_filename = file_or_filename
|
|
43
|
+
self._headers: HeaderList = []
|
|
44
|
+
self._data: ChartData = []
|
|
45
|
+
self._started = False
|
|
46
|
+
|
|
47
|
+
def read_data(self) -> bool:
|
|
48
|
+
try:
|
|
49
|
+
if not self._started:
|
|
50
|
+
self._read_data_initial()
|
|
51
|
+
self._started = True
|
|
52
|
+
else:
|
|
53
|
+
self._read_data_incr()
|
|
54
|
+
# print("incremental data read")
|
|
55
|
+
return True # File exists - haven't necessarily read anything yet
|
|
56
|
+
except FileNotFoundError:
|
|
57
|
+
# It is expected that the file is not necessarily immediately available
|
|
58
|
+
print(f"Failed to open {self._file_or_filename}")
|
|
59
|
+
return False
|
|
60
|
+
except Exception as e:
|
|
61
|
+
# Temporary - see if anything else goes wrong
|
|
62
|
+
print(e)
|
|
63
|
+
return False
|
|
64
|
+
|
|
65
|
+
@property
|
|
66
|
+
def headers(self) -> HeaderList:
|
|
67
|
+
return self._headers
|
|
68
|
+
|
|
69
|
+
@property
|
|
70
|
+
def data(self) -> ChartData:
|
|
71
|
+
return self._data
|
|
72
|
+
|
|
73
|
+
def _read_data_initial(self):
|
|
74
|
+
f = None
|
|
75
|
+
try:
|
|
76
|
+
f = self._get_file()
|
|
77
|
+
reader = csv.reader(f)
|
|
78
|
+
header = None
|
|
79
|
+
for row in reader:
|
|
80
|
+
if header is None:
|
|
81
|
+
header = row
|
|
82
|
+
else:
|
|
83
|
+
self._append_row(row)
|
|
84
|
+
finally:
|
|
85
|
+
self._close_file(f)
|
|
86
|
+
|
|
87
|
+
self._headers = header
|
|
88
|
+
|
|
89
|
+
def _read_data_incr(self):
|
|
90
|
+
f = None
|
|
91
|
+
try:
|
|
92
|
+
f = self._get_file()
|
|
93
|
+
reader = csv.reader(f)
|
|
94
|
+
nlines = len(self._data) + 1
|
|
95
|
+
# TODO: try using seek/tell
|
|
96
|
+
for i, row in enumerate(reader):
|
|
97
|
+
if i < nlines:
|
|
98
|
+
continue
|
|
99
|
+
self._append_row(row)
|
|
100
|
+
finally:
|
|
101
|
+
self._close_file(f)
|
|
102
|
+
|
|
103
|
+
def _append_row(self, row_data: list[str]) -> None:
|
|
104
|
+
self._data.append([float(f) for f in row_data])
|
|
105
|
+
|
|
106
|
+
def _get_file(self) -> TextIO:
|
|
107
|
+
if isinstance(self._file_or_filename, str):
|
|
108
|
+
return open(self._file_or_filename, newline="")
|
|
109
|
+
else:
|
|
110
|
+
return self._file_or_filename
|
|
111
|
+
|
|
112
|
+
def _close_file(self, f: TextIO):
|
|
113
|
+
# Only close if we opened it ourself
|
|
114
|
+
if f and isinstance(self._file_or_filename, str):
|
|
115
|
+
f.close()
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
class CsvChartDataReader:
|
|
119
|
+
"""Reader of chart data and metadata from a single CSV file, which
|
|
120
|
+
contains data for a single coupling interface.
|
|
121
|
+
|
|
122
|
+
The metadata is derived from the column headings in the file.
|
|
123
|
+
"""
|
|
124
|
+
|
|
125
|
+
def __init__(self, interface_name: str, csvfile: Union[str, TextIO]) -> None:
|
|
126
|
+
self._interface_name = interface_name
|
|
127
|
+
self._csv_reader = CsvReader(csvfile)
|
|
128
|
+
self._metadata: InterfaceInfo = None
|
|
129
|
+
self._data: InterfaceSeriesData = None
|
|
130
|
+
self._timestep_data = TimestepData()
|
|
131
|
+
|
|
132
|
+
def read_metadata(self) -> bool:
|
|
133
|
+
if not self._csv_reader.read_data():
|
|
134
|
+
return False
|
|
135
|
+
self._metadata = parse_csv_metadata(
|
|
136
|
+
self._interface_name, self._csv_reader.headers
|
|
137
|
+
)
|
|
138
|
+
self._init_data()
|
|
139
|
+
return True
|
|
140
|
+
|
|
141
|
+
@property
|
|
142
|
+
def metadata(self) -> InterfaceInfo:
|
|
143
|
+
return self._metadata
|
|
144
|
+
|
|
145
|
+
@property
|
|
146
|
+
def data(self) -> InterfaceSeriesData:
|
|
147
|
+
return self._data
|
|
148
|
+
|
|
149
|
+
@property
|
|
150
|
+
def timestep_data(self) -> TimestepData:
|
|
151
|
+
return self._timestep_data
|
|
152
|
+
|
|
153
|
+
def read_new_data(self):
|
|
154
|
+
self._csv_reader.read_data()
|
|
155
|
+
self._process_curr_data()
|
|
156
|
+
|
|
157
|
+
def _init_data(self):
|
|
158
|
+
series_data_list: list[SeriesData] = []
|
|
159
|
+
for i, trans_info in enumerate(self._metadata.transfer_info):
|
|
160
|
+
if not trans_info.line_suffixes:
|
|
161
|
+
series_data_list.append(SeriesData(transfer_index=i))
|
|
162
|
+
else:
|
|
163
|
+
for j in range(len(trans_info.line_suffixes)):
|
|
164
|
+
series_data_list.append(
|
|
165
|
+
SeriesData(transfer_index=i, component_index=j)
|
|
166
|
+
)
|
|
167
|
+
self._data = InterfaceSeriesData(self._metadata, series=series_data_list)
|
|
168
|
+
|
|
169
|
+
def _process_curr_data(self):
|
|
170
|
+
raw_data = self._csv_reader.data
|
|
171
|
+
last_data_len = len(self._data.series[0].data)
|
|
172
|
+
|
|
173
|
+
has_time = self._metadata.is_transient
|
|
174
|
+
for i in range(last_data_len, len(raw_data)):
|
|
175
|
+
row = raw_data[i]
|
|
176
|
+
self._timestep_data.timestep.append(round(row[1]))
|
|
177
|
+
start_index = 2
|
|
178
|
+
if has_time:
|
|
179
|
+
self._timestep_data.time.append(row[2])
|
|
180
|
+
start_index += 1
|
|
181
|
+
for j in range(start_index, len(row)):
|
|
182
|
+
self._data.series[j - start_index].data.append(row[j])
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
def _extract_transfer_value_type(header: str) -> str:
|
|
186
|
+
for value_type in ("Sum", "Weighted Average"):
|
|
187
|
+
if f" ({value_type}):" in header:
|
|
188
|
+
return value_type
|
|
189
|
+
return None
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
def _parse_header(header: str) -> tuple[SeriesType, str, str]:
|
|
193
|
+
if header.startswith("Data Transfer Convergence (RMS Change in Target Value):"):
|
|
194
|
+
ipfx = header.find(":")
|
|
195
|
+
isep = header.find(" - ", ipfx)
|
|
196
|
+
intf_disp_name = header[ipfx + 1 : isep].strip()
|
|
197
|
+
trans_disp_name = header[isep + 3 :].strip()
|
|
198
|
+
return SeriesType.CONVERGENCE, intf_disp_name, trans_disp_name
|
|
199
|
+
elif value_type := _extract_transfer_value_type(header):
|
|
200
|
+
trans_disp_name = header[: header.find(f"({value_type})")].strip()
|
|
201
|
+
part_disp_name = header[header.find(":") + 1 :].strip()
|
|
202
|
+
part_disp_name = _remove_suffix(part_disp_name)
|
|
203
|
+
return (
|
|
204
|
+
SeriesType.SUM if value_type == "Sum" else SeriesType.WEIGHTED_AVERAGE,
|
|
205
|
+
part_disp_name,
|
|
206
|
+
trans_disp_name,
|
|
207
|
+
)
|
|
208
|
+
raise ValueError(f"Invalid column header in CSV file: {header}")
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
def _remove_suffix(label: str) -> str:
|
|
212
|
+
def remove_partial_suffix(str_in: str, suffixes: tuple[str]) -> str:
|
|
213
|
+
for suffix in suffixes:
|
|
214
|
+
suffix = f" {suffix}"
|
|
215
|
+
if str_in.endswith(suffix):
|
|
216
|
+
return str_in[: len(str_in) - len(suffix)]
|
|
217
|
+
return str_in
|
|
218
|
+
|
|
219
|
+
# Suffix has format "[ <x|y|z>][ <real|imag>]" so remove real/imag first
|
|
220
|
+
label = remove_partial_suffix(label, ("real", "imag"))
|
|
221
|
+
label = remove_partial_suffix(label, ("x", "y", "z"))
|
|
222
|
+
return label
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
def _parse_suffix(header: str, part_disp_name: str) -> str:
|
|
226
|
+
idx = header.find(f": {part_disp_name} ")
|
|
227
|
+
if idx == -1:
|
|
228
|
+
return ""
|
|
229
|
+
return header[idx + len(part_disp_name) + 3 :].strip()
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
def parse_csv_metadata(interface_name: str, headers: list[str]) -> InterfaceInfo:
|
|
233
|
+
intf_info = InterfaceInfo(name=interface_name)
|
|
234
|
+
assert headers[0] == "Iteration"
|
|
235
|
+
assert headers[1] == "Step"
|
|
236
|
+
intf_info.is_transient = headers[2] == "Time"
|
|
237
|
+
|
|
238
|
+
start_index = 3 if intf_info.is_transient else 2
|
|
239
|
+
prev_part_name = ""
|
|
240
|
+
|
|
241
|
+
transfer_disambig: dict[str, int] = {}
|
|
242
|
+
for i in range(start_index, len(headers)):
|
|
243
|
+
header = headers[i]
|
|
244
|
+
data_index = i - start_index
|
|
245
|
+
series_type, intf_or_part_disp_name, trans_disp_name = _parse_header(header)
|
|
246
|
+
if series_type == SeriesType.CONVERGENCE:
|
|
247
|
+
prev_part_name = ""
|
|
248
|
+
if trans_disp_name in transfer_disambig:
|
|
249
|
+
transfer_disambig[trans_disp_name] += 1
|
|
250
|
+
else:
|
|
251
|
+
transfer_disambig[trans_disp_name] = 0
|
|
252
|
+
|
|
253
|
+
intf_disp_name = intf_or_part_disp_name
|
|
254
|
+
if data_index == 0:
|
|
255
|
+
assert intf_info.display_name == ""
|
|
256
|
+
intf_info.display_name = intf_disp_name
|
|
257
|
+
series_info = TransferSeriesInfo(
|
|
258
|
+
data_index,
|
|
259
|
+
series_type,
|
|
260
|
+
transfer_display_name=trans_disp_name,
|
|
261
|
+
disambiguation_index=transfer_disambig[trans_disp_name],
|
|
262
|
+
)
|
|
263
|
+
intf_info.transfer_info.append(series_info)
|
|
264
|
+
else:
|
|
265
|
+
part_disp_name = intf_or_part_disp_name
|
|
266
|
+
suffix = _parse_suffix(header, part_disp_name)
|
|
267
|
+
if suffix:
|
|
268
|
+
if prev_part_name != part_disp_name:
|
|
269
|
+
# Start a new series info for a group of components
|
|
270
|
+
# Thus if there are 3 components, say, they will
|
|
271
|
+
# implicitly have data indexes, data_index, data_index+1,
|
|
272
|
+
# data_index+2, and the next TransferSeriesInfo will
|
|
273
|
+
# have index data_index+3.
|
|
274
|
+
intf_info.transfer_info.append(
|
|
275
|
+
TransferSeriesInfo(
|
|
276
|
+
data_index,
|
|
277
|
+
series_type,
|
|
278
|
+
transfer_display_name=trans_disp_name,
|
|
279
|
+
disambiguation_index=transfer_disambig[trans_disp_name],
|
|
280
|
+
participant_display_name=part_disp_name,
|
|
281
|
+
line_suffixes=[suffix],
|
|
282
|
+
)
|
|
283
|
+
)
|
|
284
|
+
prev_part_name = part_disp_name
|
|
285
|
+
else:
|
|
286
|
+
# Append component info to current series info
|
|
287
|
+
intf_info.transfer_info[-1].line_suffixes.append(suffix)
|
|
288
|
+
else:
|
|
289
|
+
prev_part_name = ""
|
|
290
|
+
intf_info.transfer_info.append(
|
|
291
|
+
TransferSeriesInfo(
|
|
292
|
+
data_index,
|
|
293
|
+
series_type,
|
|
294
|
+
transfer_display_name=trans_disp_name,
|
|
295
|
+
disambiguation_index=transfer_disambig[trans_disp_name],
|
|
296
|
+
participant_display_name=part_disp_name,
|
|
297
|
+
)
|
|
298
|
+
)
|
|
299
|
+
return intf_info
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# Copyright (C) 2023 - 2024 ANSYS, Inc. and/or its affiliates.
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
#
|
|
4
|
+
#
|
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
# furnished to do so, subject to the following conditions:
|
|
11
|
+
#
|
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
# copies or substantial portions of the Software.
|
|
14
|
+
#
|
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
# SOFTWARE.
|
|
22
|
+
|
|
23
|
+
import threading
|
|
24
|
+
import time
|
|
25
|
+
from typing import Callable, TextIO, Union
|
|
26
|
+
|
|
27
|
+
from ansys.systemcoupling.core.charts.chart_datatypes import SeriesData
|
|
28
|
+
from ansys.systemcoupling.core.charts.csv_chartdata import CsvChartDataReader
|
|
29
|
+
from ansys.systemcoupling.core.charts.message_dispatcher import Message, MsgType
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class LiveCsvDataSource:
|
|
33
|
+
def __init__(
|
|
34
|
+
self,
|
|
35
|
+
interface_name: str,
|
|
36
|
+
csvfile: Union[str, TextIO],
|
|
37
|
+
put_msg: Callable[[Message], None],
|
|
38
|
+
):
|
|
39
|
+
self._csv_reader = CsvChartDataReader(interface_name, csvfile)
|
|
40
|
+
self._put_msg = put_msg
|
|
41
|
+
self._is_cancelled = threading.Event()
|
|
42
|
+
self._last_data_len = []
|
|
43
|
+
|
|
44
|
+
def cancel(self):
|
|
45
|
+
self._is_cancelled.set()
|
|
46
|
+
|
|
47
|
+
def read_data(self):
|
|
48
|
+
|
|
49
|
+
while not self._is_cancelled.is_set():
|
|
50
|
+
if not self._csv_reader.read_metadata():
|
|
51
|
+
time.sleep(0.5)
|
|
52
|
+
else:
|
|
53
|
+
self._put_msg(
|
|
54
|
+
Message(type=MsgType.METADATA, data=self._csv_reader.metadata)
|
|
55
|
+
)
|
|
56
|
+
break
|
|
57
|
+
|
|
58
|
+
last_round = False
|
|
59
|
+
while True:
|
|
60
|
+
self._csv_reader.read_new_data()
|
|
61
|
+
data = self._csv_reader.data
|
|
62
|
+
if not self._last_data_len:
|
|
63
|
+
self._last_data_len = [0] * len(data.series)
|
|
64
|
+
for i, line_series in enumerate(data.series):
|
|
65
|
+
start_index = self._last_data_len[i]
|
|
66
|
+
new_data_len = len(line_series.data)
|
|
67
|
+
|
|
68
|
+
if new_data_len - start_index == 0:
|
|
69
|
+
continue
|
|
70
|
+
|
|
71
|
+
line_series_incr = SeriesData(
|
|
72
|
+
line_series.transfer_index,
|
|
73
|
+
line_series.component_index,
|
|
74
|
+
start_index=start_index,
|
|
75
|
+
data=line_series.data[start_index:],
|
|
76
|
+
)
|
|
77
|
+
self._put_msg(Message(type=MsgType.SERIES_DATA, data=line_series_incr))
|
|
78
|
+
self._last_data_len[i] = new_data_len
|
|
79
|
+
|
|
80
|
+
if last_round:
|
|
81
|
+
self._put_msg(Message(type=MsgType.END_OF_DATA))
|
|
82
|
+
break
|
|
83
|
+
elif self._is_cancelled.is_set():
|
|
84
|
+
# Allow opportunity for any trailing updates to file
|
|
85
|
+
last_round = True
|
|
86
|
+
|
|
87
|
+
time.sleep(0.5)
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# Copyright (C) 2023 - 2024 ANSYS, Inc. and/or its affiliates.
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
#
|
|
4
|
+
#
|
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
# furnished to do so, subject to the following conditions:
|
|
11
|
+
#
|
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
# copies or substantial portions of the Software.
|
|
14
|
+
#
|
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
# SOFTWARE.
|
|
22
|
+
|
|
23
|
+
from dataclasses import dataclass
|
|
24
|
+
from enum import IntEnum
|
|
25
|
+
import queue
|
|
26
|
+
from typing import Protocol, Union
|
|
27
|
+
|
|
28
|
+
from ansys.systemcoupling.core.charts.chart_datatypes import (
|
|
29
|
+
InterfaceInfo,
|
|
30
|
+
SeriesData,
|
|
31
|
+
TimestepData,
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class PlotterProtocol(Protocol):
|
|
36
|
+
def set_metadata(self, metadata: InterfaceInfo): ...
|
|
37
|
+
def set_timestep_data(self, timestep_data: TimestepData): ...
|
|
38
|
+
def update_line_series(self, series_data: SeriesData): ...
|
|
39
|
+
def close(self): ...
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class MsgType(IntEnum):
|
|
43
|
+
NO_DATA_AVAILABLE = 1
|
|
44
|
+
END_OF_DATA = 2
|
|
45
|
+
CLOSE_PLOT = 3
|
|
46
|
+
METADATA = 4
|
|
47
|
+
TIMESTEP_DATA = 5
|
|
48
|
+
SERIES_DATA = 6
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
@dataclass
|
|
52
|
+
class Message:
|
|
53
|
+
type: MsgType
|
|
54
|
+
data: Union[InterfaceInfo, TimestepData, SeriesData, None] = None
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
class MessageDispatcher:
|
|
58
|
+
def __init__(self):
|
|
59
|
+
self._q = queue.Queue()
|
|
60
|
+
|
|
61
|
+
def set_plotter(self, plotter: PlotterProtocol):
|
|
62
|
+
self._plotter = plotter
|
|
63
|
+
|
|
64
|
+
def put_msg(self, msg: Message):
|
|
65
|
+
self._q.put(msg)
|
|
66
|
+
|
|
67
|
+
def dispatch_messages(self):
|
|
68
|
+
while True:
|
|
69
|
+
try:
|
|
70
|
+
msg: Message = self._q.get(timeout=0.001)
|
|
71
|
+
msg_t = msg.type
|
|
72
|
+
print(f"dispatch message of type: {msg.type.name}")
|
|
73
|
+
if msg_t == MsgType.METADATA:
|
|
74
|
+
self._plotter.set_metadata(msg.data)
|
|
75
|
+
elif msg_t == MsgType.TIMESTEP_DATA:
|
|
76
|
+
self._plotter.set_timestep_data(msg.data)
|
|
77
|
+
elif msg_t == MsgType.SERIES_DATA:
|
|
78
|
+
self._plotter.update_line_series(msg.data)
|
|
79
|
+
elif msg_t in (MsgType.END_OF_DATA, MsgType.NO_DATA_AVAILABLE):
|
|
80
|
+
return
|
|
81
|
+
elif msg_t == MsgType.CLOSE_PLOT:
|
|
82
|
+
self._plotter.close()
|
|
83
|
+
except queue.Empty:
|
|
84
|
+
return
|