Skip to content

Commit c470204

Browse files
authored
Merge pull request #119 from ChannelFinder/pvws_pvstatus_check
Allow subscribing to PVs with inactive CF pvStatus
2 parents 974ebea + 7161ec0 commit c470204

File tree

5 files changed

+30
-16
lines changed

5 files changed

+30
-16
lines changed

.env

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ REACT_APP_CF_URL=http://localhost:8080/ChannelFinder
6464
# Limit the number of CF results returned by a given query
6565
REACT_APP_CF_MAX_RESULTS=
6666

67-
# Optional CF properties to include (https://github.com/ChannelFinder/recsync/blob/master/server/cf.conf#L46)
67+
# Optional CF properties to include (https://github.com/ChannelFinder/recsync/blob/master/server/demo.conf#L74)
6868
# recordType
6969
REACT_APP_CF_RECORD_TYPE=false
7070
# recordDesc
@@ -111,6 +111,11 @@ REACT_APP_LIVE_MONITOR_MAX=100
111111
# can be used to limit giant waveforms coming across the websocket connection as a mitigation
112112
REACT_APP_PVWS_ALLOW_WAVEFORMS=false
113113

114+
# By default, PV Info does not allow the user to subscribe to PVs with a status that is not "Active".
115+
# Switch this to true to allow PV Info to attempt to subscribe to these PVs. This could be useful
116+
# if your recceiver instance is not working but the PVs themselves are alive and accessible.
117+
REACT_APP_PVWS_IGNORE_CF_PVSTATUS=false
118+
114119
######################################################################################
115120
# Archiver Web Viewer
116121
######################################################################################

src/components/help/Help.jsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,12 @@ function Help() {
8585
</ul>
8686
<li><strong>Status</strong></li>
8787
<ul>
88+
8889
<li>
89-
Current status of this PV. Either Active or Inactive. Inactive means the PV is not up and indicates a problem with the IOC. If the PV is inactive then the PV value monitor
90-
checkbox will be disabled.
90+
Current status of this PV. Either Active or Inactive. Inactive means the PV is not synchronized with the recsync server and indicates a problem with the IOC or recsync.
91+
{ import.meta.env.REACT_APP_PVWS_IGNORE_CF_PVSTATUS !== "true" &&
92+
<li>If the PV is inactive then the PV value monitor checkbox will be disabled.</li>
93+
}
9194
</li>
9295
</ul>
9396
<li><strong>Record Type</strong></li>

src/components/home/queryresults/valuecheckbox/ValueCheckbox.jsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ function ValueCheckbox(props) {
2929
}
3030

3131
useEffect(() => {
32-
if (props.pvStatus === "Inactive" || (import.meta.env.REACT_APP_PVWS_ALLOW_WAVEFORMS !== "true" && props.recordType === "waveform")) {
32+
if (props.pvStatus !== "Active" && import.meta.env.REACT_APP_PVWS_IGNORE_CF_PVSTATUS !== "true") {
33+
setEnabled(false);
34+
}
35+
else if (props.recordType === "waveform" && import.meta.env.REACT_APP_PVWS_ALLOW_WAVEFORMS !== "true") {
3336
setEnabled(false);
3437
}
3538
}, [props.pvStatus, props.recordType])
@@ -49,7 +52,7 @@ function ValueCheckbox(props) {
4952
<Tooltip arrow title={<div>Monitor<br />{props.pvName}</div>}>
5053
<Checkbox
5154
checked={props.checked[props.id] && enabled}
52-
disabled={props.pvStatus === "Inactive" || (import.meta.env.REACT_APP_PVWS_ALLOW_WAVEFORMS !== "true" && props.recordType === "waveform")}
55+
disabled={!enabled}
5356
color="primary"
5457
onChange={handleMonitorPVChange(props.id)} >
5558
</Checkbox>

src/components/pv/PV.jsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,12 @@ function PV(props) {
176176
</Box>
177177
{
178178
import.meta.env.REACT_APP_USE_PVWS === "true" ?
179-
import.meta.env.REACT_APP_PVWS_ALLOW_WAVEFORMS === "true" ?
180-
<FormControlLabel control={<Checkbox color="primary" checked={pvMonitoring} onChange={handlePVMonitoringChange}></Checkbox>} disabled={pvData?.pvStatus?.value === "Inactive"} label="Enable Live PV Monitoring" />
179+
<FormControlLabel
180+
control={<Checkbox color="primary" checked={pvMonitoring} onChange={handlePVMonitoringChange}></Checkbox>}
181+
disabled={!((import.meta.env.REACT_APP_PVWS_IGNORE_CF_PVSTATUS === "true" || pvData?.pvStatus?.value === "Active") && (import.meta.env.REACT_APP_PVWS_ALLOW_WAVEFORMS === "true" || pvData?.recordType?.value !== "waveform"))}
182+
label="Enable Live PV Monitoring" />
181183
:
182-
<FormControlLabel control={<Checkbox color="primary" checked={pvMonitoring} onChange={handlePVMonitoringChange}></Checkbox>} disabled={pvData?.pvStatus?.value === "Inactive" || pvData?.recordType?.value === "waveform"} label="Enable Live PV Monitoring" />
183-
: null
184+
null
184185
}
185186
<Box sx={{ border: 1, borderColor: '#D1D5DB', borderRadius: 1, boxShadow: 2, mb: 2, overflow: "hidden" }}>
186187
<Accordion expanded={detailsExpanded} onChange={handleDetailExpandedChange()}>

src/components/pv/valuetable/ValueTable.jsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,22 +56,24 @@ function ValueTable(props) {
5656
if (props.pvData === null || Object.keys(props.pvData).length === 0 || props.isLoading) {
5757
return;
5858
}
59-
else if (props.pvData.pvStatus?.value === "Inactive") {
60-
handleErrorMessage("Can't show live PV values - PV is in Inactive state");
61-
handleSeverity("warning");
62-
handleOpenErrorAlert(true);
63-
}
64-
else if (import.meta.env.REACT_APP_PVWS_ALLOW_WAVEFORMS !== "true" && props.pvData.recordType?.value === "waveform") {
59+
const status = props.pvData.pvStatus?.value || "Unknown";
60+
61+
if (import.meta.env.REACT_APP_PVWS_ALLOW_WAVEFORMS !== "true" && props.pvData.recordType?.value === "waveform") {
6562
handleErrorMessage("Can't show live PV values - Waveform record type not supported");
6663
handleSeverity("warning");
6764
handleOpenErrorAlert(true);
6865
}
69-
else if (props.pvData.pvStatus?.value === "Active") {
66+
else if (import.meta.env.REACT_APP_PVWS_IGNORE_CF_PVSTATUS === "true" || status === "Active") {
7067
if (!subscribed) {
7168
sendJsonMessage({ "type": "subscribe", "pvs": [props.pvName] });
7269
setSubscribed(true);
7370
}
7471
}
72+
else {
73+
handleErrorMessage(`Can't show live PV values - PV is in ${status} state`);
74+
handleSeverity("warning");
75+
handleOpenErrorAlert(true);
76+
}
7577
}
7678
else {
7779
if (subscribed) {

0 commit comments

Comments
 (0)