@@ -4,17 +4,11 @@ import {
44 IfcPVWSMessage ,
55 IfcPVWSRequest ,
66 instList ,
7- instListEntryWithRunstatePVandValue ,
87 PVWSRequestType ,
98} from "@/app/types" ;
109import useWebSocket from "react-use-websocket" ;
1110import { instListPV , instListSubscription , socketURL } from "@/app/commonVars" ;
1211import { instListFromBytes } from "@/app/components/dehex_and_decompress" ;
13- import {
14- updateInstrumentRunstate ,
15- updateInstrumentRunstatePV ,
16- updateTargetStationBeamCurrent ,
17- } from "@/app/wall/utils" ;
1812import TargetStation from "@/app/components/TargetStation" ;
1913import ScienceGroup from "@/app/components/ScienceGroup" ;
2014
@@ -23,11 +17,8 @@ const instrumentsExcludeList = ["SUPPORT"];
2317
2418export function createInstrumentGroups (
2519 instruments : instList ,
26- ) : Map < string , Array < instListEntryWithRunstatePVandValue > > {
27- let newInstrumentGroups : Map <
28- string ,
29- Array < instListEntryWithRunstatePVandValue >
30- > = new Map ( ) ;
20+ ) : Map < string , instList > {
21+ let newInstrumentGroups : Map < string , instList > = new Map ( ) ;
3122 for ( const inst of instruments ) {
3223 for ( const group of inst . groups ) {
3324 if ( ! instrumentsExcludeList . includes ( group ) ) {
@@ -42,27 +33,6 @@ export function createInstrumentGroups(
4233 return newInstrumentGroups ;
4334}
4435
45- export function createTargetStations (
46- instruments : instList ,
47- ) : Map < string , Array < instListEntryWithRunstatePVandValue > > {
48- let newInstrumentGroups : Map <
49- string ,
50- Array < instListEntryWithRunstatePVandValue >
51- > = new Map ( ) ;
52- for ( const inst of instruments ) {
53- for ( const group of inst . targetStation ) {
54- if ( ! instrumentsExcludeList . includes ( group ) ) {
55- if ( ! newInstrumentGroups . has ( group ) ) {
56- // This is a new science group so create a new entry
57- newInstrumentGroups . set ( group , [ ] ) ;
58- }
59- newInstrumentGroups . get ( group ) ! . push ( inst ) ;
60- }
61- }
62- }
63- return newInstrumentGroups ;
64- }
65-
6636/* c8 ignore start */
6737export default function InstrumentsDisplay ( {
6838 sortByGroups = false ,
@@ -73,7 +43,7 @@ export default function InstrumentsDisplay({
7343
7444 const ts1BeamCurrentPv = "AC:TS1:BEAM:CURR" ;
7545 const ts2BeamCurrentPv = "AC:TS2:BEAM:CURR" ;
76- const muonTargetCurrentPv = "AC:MUON:BEAM:CURR" ; //TODO make this exist
46+ const muonTargetCurrentPv = "AC:MUON:BEAM:CURR" ;
7747
7848 const [ instList , setInstList ] = useState < instList > ( [ ] ) ;
7949
@@ -140,7 +110,7 @@ export default function InstrumentsDisplay({
140110 setMuonCurrent ( updatedPVnum ) ;
141111 }
142112 }
143- } , [ lastJsonMessage , sendJsonMessage ] ) ;
113+ } , [ lastJsonMessage , sendJsonMessage , instList ] ) ;
144114
145115 return (
146116 < div >
@@ -152,17 +122,38 @@ export default function InstrumentsDisplay({
152122 < ScienceGroup key = { name } name = { name } instruments = { instruments } />
153123 ) ;
154124 } ) }
155- { ! sortByGroups &&
156- instList . map ( ( targetStation ) => {
157- return (
158- < TargetStation
159- key = { targetStation . targetStation }
160- name = { targetStation . targetStation }
161- instruments = { targetStation . instruments }
162- beamCurrent = { targetStation . beamCurrent }
163- />
164- ) ;
165- } ) }
125+ { ! sortByGroups && (
126+ < >
127+ < TargetStation
128+ name = { "TS1" }
129+ instruments = { instList . filter (
130+ ( instrument ) => instrument . targetStation == "TS1" ,
131+ ) }
132+ beamCurrent = { ts1Current }
133+ />
134+ < TargetStation
135+ name = { "MUON" }
136+ instruments = { instList . filter (
137+ ( instrument ) => instrument . targetStation == "MUON" ,
138+ ) }
139+ beamCurrent = { muonCurrent }
140+ />
141+ < TargetStation
142+ name = { "TS2" }
143+ instruments = { instList . filter (
144+ ( instrument ) => instrument . targetStation == "TS2" ,
145+ ) }
146+ beamCurrent = { ts2Current }
147+ />
148+ < TargetStation
149+ name = { "MISC" }
150+ instruments = { instList . filter (
151+ ( instrument ) => instrument . targetStation == "MISC" ,
152+ ) }
153+ beamCurrent = { undefined }
154+ />
155+ </ >
156+ ) }
166157 </ div >
167158 ) ;
168159}
0 commit comments