Skip to content

Monitors

Monitors interface with widgets to surface process variable information. They are initialized using a lume-model variable and a controller used to access values over EPICs.

PVImage

Monitor for updating and formatting image data.

Attributes:

Name Type Description
variable ImageVariable

Image process variable to be displayed.

controller Controller

Controller object for accessing process variable.

pvname str

Name of the process variable to access.

axis_units str

Units associated with the image axes.

axis_labels str

Labels associated with the image axes.

Source code in lume_epics/client/monitors.py
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
55
56
57
58
59
60
61
62
class PVImage:
    """
    Monitor for updating and formatting image data.

    Attributes:
        variable (ImageVariable): Image process variable to be displayed.

        controller (Controller): Controller object for accessing process variable.

        pvname (str): Name of the process variable to access.

        axis_units (str): Units associated with the image axes.

        axis_labels (str): Labels associated with the image axes.

    """

    def __init__(self, variable: ImageVariable, controller: Controller,) -> None:
        """Initialize monitor for an image variable.

        Args:
            variable (ImageVariable): Image process variable to be displayed.

            controller (Controller): Controller object for accessing process variable.

        """
        self.units = None
        # check if units has been set
        if "units" in variable.__fields_set__:
            self.units = variable.units.split(":")

        self.varname = variable.name
        self.controller = controller
        self.axis_labels = variable.axis_labels
        self.axis_units = variable.axis_units

    def poll(self) -> Dict[str, list]:
        """Collects image data and builds image data dictionary.

        """

        return self.controller.get_image(self.varname)

__init__(variable, controller)

Initialize monitor for an image variable.

Parameters:

Name Type Description Default
variable ImageVariable

Image process variable to be displayed.

required
controller Controller

Controller object for accessing process variable.

required
Source code in lume_epics/client/monitors.py
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
def __init__(self, variable: ImageVariable, controller: Controller,) -> None:
    """Initialize monitor for an image variable.

    Args:
        variable (ImageVariable): Image process variable to be displayed.

        controller (Controller): Controller object for accessing process variable.

    """
    self.units = None
    # check if units has been set
    if "units" in variable.__fields_set__:
        self.units = variable.units.split(":")

    self.varname = variable.name
    self.controller = controller
    self.axis_labels = variable.axis_labels
    self.axis_units = variable.axis_units

poll()

Collects image data and builds image data dictionary.

Source code in lume_epics/client/monitors.py
57
58
59
60
61
62
def poll(self) -> Dict[str, list]:
    """Collects image data and builds image data dictionary.

    """

    return self.controller.get_image(self.varname)

PVScalar

Monitor for scalar process variables.

Attributes:

Name Type Description
variable ScalarVariable

Variable to monitor for value.

controller Controller

Controller object for accessing process variable.

units str

Units associated with the variable.

varname str

Name of the model variable to access.

Source code in lume_epics/client/monitors.py
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
class PVScalar:
    """
    Monitor for scalar process variables.

    Attributes:
        variable (ScalarVariable): Variable to monitor for value.

        controller (Controller): Controller object for accessing process variable.

        units (str): Units associated with the variable.

        varname (str): Name of the model variable to access.

    """

    def __init__(self, variable: ScalarVariable, controller: Controller,) -> None:
        """Initializes monitor attributes.

        Args:
            variable (ScalarVariable):  Variable to monitor for value.

            controller (Controller): Controller object for accessing process variable.
        """
        self.units = None
        # check if units has been set
        if "units" in variable.__fields_set__:
            self.units = variable.units
        self.varname = variable.name
        self.controller = controller

    def poll(self) -> Tuple[np.ndarray]:
        """
        Poll variable for value,

        """
        return self.controller.get_value(self.varname)

__init__(variable, controller)

Initializes monitor attributes.

Parameters:

Name Type Description Default
variable ScalarVariable

Variable to monitor for value.

required
controller Controller

Controller object for accessing process variable.

required
Source code in lume_epics/client/monitors.py
139
140
141
142
143
144
145
146
147
148
149
150
151
152
def __init__(self, variable: ScalarVariable, controller: Controller,) -> None:
    """Initializes monitor attributes.

    Args:
        variable (ScalarVariable):  Variable to monitor for value.

        controller (Controller): Controller object for accessing process variable.
    """
    self.units = None
    # check if units has been set
    if "units" in variable.__fields_set__:
        self.units = variable.units
    self.varname = variable.name
    self.controller = controller

poll()

Poll variable for value,

Source code in lume_epics/client/monitors.py
154
155
156
157
158
159
def poll(self) -> Tuple[np.ndarray]:
    """
    Poll variable for value,

    """
    return self.controller.get_value(self.varname)

PVTimeSeries

Monitor for time series variables.

Attributes:

Name Type Description
time np.ndarray

Array of times sampled.

data np.ndarray

Array of sampled data.

variable ScalarVariable

Variable monitored for time series.

controller Controller

Controller object for accessing process variable.

units str

Units associated with the variable

varname str

Name of the model variable to access

Source code in lume_epics/client/monitors.py
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
class PVTimeSeries:
    """
    Monitor for time series variables.

    Attributes:
        time (np.ndarray): Array of times sampled.

        data (np.ndarray): Array of sampled data.

        variable (ScalarVariable): Variable monitored for time series.

        controller (Controller): Controller object for accessing process variable.

        units (str): Units associated with the variable

        varname (str): Name of the model variable to access

    """

    def __init__(self, variable: ScalarVariable, controller: Controller,) -> None:
        """Initializes monitor attributes.

        Args:
            variable (ScalarVariable): Variable to monitor for time series

            controller (Controller): Controller object for accessing process variable.

        """
        self.varname = variable.name
        self.tstart = time.time()
        self.time = np.array([])
        self.data = np.array([])

        self.units = None
        # check if units has been set
        if "units" in variable.__fields_set__:
            self.units = variable.units

        self.controller = controller

    def poll(self) -> Tuple[np.ndarray]:
        """
        Collects image data via appropriate protocol and returns time and data.

        """
        t = datetime.now()

        v = self.controller.get_value(self.varname)

        self.time = np.append(self.time, t)
        self.data = np.append(self.data, v)

        return self.time, self.data

    def reset(self) -> None:
        self.time = np.array([])
        self.data = np.array([])

__init__(variable, controller)

Initializes monitor attributes.

Parameters:

Name Type Description Default
variable ScalarVariable

Variable to monitor for time series

required
controller Controller

Controller object for accessing process variable.

required
Source code in lume_epics/client/monitors.py
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
def __init__(self, variable: ScalarVariable, controller: Controller,) -> None:
    """Initializes monitor attributes.

    Args:
        variable (ScalarVariable): Variable to monitor for time series

        controller (Controller): Controller object for accessing process variable.

    """
    self.varname = variable.name
    self.tstart = time.time()
    self.time = np.array([])
    self.data = np.array([])

    self.units = None
    # check if units has been set
    if "units" in variable.__fields_set__:
        self.units = variable.units

    self.controller = controller

poll()

Collects image data via appropriate protocol and returns time and data.

Source code in lume_epics/client/monitors.py
105
106
107
108
109
110
111
112
113
114
115
116
117
def poll(self) -> Tuple[np.ndarray]:
    """
    Collects image data via appropriate protocol and returns time and data.

    """
    t = datetime.now()

    v = self.controller.get_value(self.varname)

    self.time = np.append(self.time, t)
    self.data = np.append(self.data, v)

    return self.time, self.data