44 IfcInstrumentStatus ,
55 IfcPVWSMessage ,
66 IfcPVWSRequest ,
7+ PVWSRequestType ,
78 targetStation ,
89} from "@/app/types" ;
910import useWebSocket from "react-use-websocket" ;
@@ -12,6 +13,7 @@ import { instListFromBytes } from "@/app/components/dehex_and_decompress";
1213import {
1314 updateInstrumentRunstate ,
1415 updateInstrumentRunstatePV ,
16+ updateTargetStationBeamCurrent ,
1517} from "@/app/wall/utils" ;
1618import TargetStation from "@/app/components/TargetStation" ;
1719import ScienceGroup from "@/app/components/ScienceGroup" ;
@@ -49,9 +51,13 @@ export default function InstrumentsDisplay({
4951} ) {
5052 const runstatePV = "DAE:RUNSTATE_STR" ;
5153
54+ const ts1BeamCurrentPv = "AC:TS1:BEAM:CURR" ;
55+ const ts2BeamCurrentPv = "AC:TS2:BEAM:CURR" ;
56+
5257 const [ data , setData ] = useState < Array < targetStation > > ( [
5358 {
5459 targetStation : "Target Station 1" ,
60+ beamCurrentPv : ts1BeamCurrentPv ,
5561 instruments : [
5662 { name : "ALF" } ,
5763 { name : "ARGUS" } ,
@@ -86,6 +92,7 @@ export default function InstrumentsDisplay({
8692 } ,
8793 {
8894 targetStation : "Target Station 2" ,
95+ beamCurrentPv : ts2BeamCurrentPv ,
8996 instruments : [
9097 { name : "CHIPIR" } ,
9198 { name : "IMAT" } ,
@@ -149,6 +156,10 @@ export default function InstrumentsDisplay({
149156 useEffect ( ( ) => {
150157 // On page load, subscribe to the instrument list as it's required to get each instrument's PV prefix.
151158 sendJsonMessage ( instListSubscription ) ;
159+ sendJsonMessage ( {
160+ type : PVWSRequestType . subscribe ,
161+ pvs : [ ts1BeamCurrentPv , ts2BeamCurrentPv ] ,
162+ } ) ;
152163 } , [ sendJsonMessage ] ) ;
153164
154165 useEffect ( ( ) => {
@@ -161,6 +172,7 @@ export default function InstrumentsDisplay({
161172 const updatedPVName : string = updatedPV . pv ;
162173 const updatedPVbytes : string | null | undefined = updatedPV . b64byt ;
163174 let updatedPVvalue : string | null | undefined = updatedPV . text ;
175+ let updatedPVnum : number | null | undefined = updatedPV . value ;
164176
165177 if ( updatedPVName == instListPV && updatedPVbytes != null ) {
166178 const instListDict = instListFromBytes ( updatedPVbytes ) ;
@@ -174,6 +186,17 @@ export default function InstrumentsDisplay({
174186 ) ;
175187 } ) ;
176188 }
189+ } else if (
190+ updatedPVName == ts1BeamCurrentPv ||
191+ updatedPVName == ts2BeamCurrentPv
192+ ) {
193+ setData ( ( prev ) => {
194+ return updateTargetStationBeamCurrent (
195+ prev ,
196+ updatedPVName ,
197+ updatedPVnum ,
198+ ) ;
199+ } ) ;
177200 } else if ( updatedPVvalue ) {
178201 setData ( ( prev ) => {
179202 return updateInstrumentRunstate ( prev , updatedPVName , updatedPVvalue ) ;
@@ -198,6 +221,7 @@ export default function InstrumentsDisplay({
198221 key = { targetStation . targetStation }
199222 name = { targetStation . targetStation }
200223 instruments = { targetStation . instruments }
224+ beamCurrent = { targetStation . beamCurrent }
201225 />
202226 ) ;
203227 } ) }
0 commit comments