Skip to content
This repository was archived by the owner on Mar 12, 2019. It is now read-only.

Commit 02a2a41

Browse files
author
kakwok
authored
Merge pull request #404 from HCALRunControl/simplifyQGnavigation
Simplify QG navigation
2 parents 6c3d196 + af4e027 commit 02a2a41

10 files changed

Lines changed: 372 additions & 27 deletions

gui/js/hcalui.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ function makedropdown(availableRunConfigs, availableLocalRunKeys) {
241241
if (runConfigMap[localRunKeysArray[i]].hasOwnProperty('singlePartitionFM')) { singlePartitionFM=runConfigMap[localRunKeysArray[i]].singlePartitionFM; }
242242
eventsToTake = "default";
243243
if (runConfigMap[localRunKeysArray[i]].hasOwnProperty('eventsToTake')) { eventsToTake=runConfigMap[localRunKeysArray[i]].eventsToTake; }
244-
dropdownoption = dropdownoption + "<option value='" + runConfigMap[localRunKeysArray[i]].snippet + "' maskedresources='" + runConfigMap[localRunKeysArray[i]].maskedapps +"' maskedFM='" + maskedFM + "' + singlePartitionFM='" + singlePartitionFM+ "' eventsToTake='" + eventsToTake+ "' ";
244+
dropdownoption = dropdownoption + "<option value='" + runConfigMap[localRunKeysArray[i]].snippet + "' maskedresources='" + runConfigMap[localRunKeysArray[i]].maskedapps + "' maskedcrates='" + runConfigMap[localRunKeysArray[i]].maskedcrates +"' maskedFM='" + maskedFM + "' + singlePartitionFM='" + singlePartitionFM+ "' eventsToTake='" + eventsToTake+ "' ";
245245

246246
if (localRunKeysArray[i] != $("#LOCAL_RUNKEY_SELECTED").val()) {
247247
dropdownoption = dropdownoption + "' >" + localRunKeysArray[i] + "</option>";
@@ -287,6 +287,10 @@ function fillMask() {
287287
for (var i = 0; i < userXMLmaskedApps.length; i++) {
288288
if (userXMLmaskedApps[i] != "") finalMasks.push(userXMLmaskedApps[i]);
289289
}
290+
var userXMLmaskedCrates = $('#dropdown option:selected').attr("maskedcrates").split("|");
291+
for (var i = 0; i < userXMLmaskedCrates.length; i++) {
292+
if (userXMLmaskedCrates[i] != "") finalMasks.push("physicalCrate_" + userXMLmaskedCrates[i]);
293+
}
290294
$('#MASKED_RESOURCES').val(JSON.stringify(finalMasks));
291295
var masksToShow = "[";
292296
var availableResources = getAvailableResources();

schema/grandmaster.xsd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
<xs:attribute type="xs:string" name="maskedFM" use="optional"/>
4141
<xs:attribute type="xs:string" name="singlePartitionFM" use="optional"/>
4242
<xs:attribute type="xs:string" name="maskedapps" use="optional"/>
43+
<xs:attribute type="xs:string" name="maskedcrates" use="optional"/>
4344
</xs:complexType>
4445
</xs:element>
4546
</xs:sequence>

src/rcms/fm/app/level1/HCALEventHandler.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import org.w3c.dom.Node;
3636
import org.w3c.dom.Text;
3737

38+
import rcms.fm.app.level1.HCALqgMapper.abstractQGmapReader;
3839
import rcms.fm.fw.StateEnteredEvent;
3940
import rcms.fm.fw.parameter.Parameter;
4041
import rcms.fm.fw.parameter.FunctionManagerParameter;
@@ -88,6 +89,7 @@ public class HCALEventHandler extends UserEventHandler {
8889
protected HCALFunctionManager functionManager = null;
8990
static RCMSLogger logger = new RCMSLogger(HCALEventHandler.class);
9091
public HCALxmlHandler xmlHandler = null;
92+
public abstractQGmapReader qgMapper = null;
9193
public LogSessionConnector logSessionConnector; // Connector for logsession DB
9294

9395
// Essential xdaq stuff

src/rcms/fm/app/level1/HCALMasker.java

Lines changed: 48 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import java.util.HashMap;
66
import java.util.TreeMap;
77
import java.util.Arrays;
8+
import java.util.Collection;
89
import java.util.ArrayList;
910

1011
import rcms.util.logger.RCMSLogger;
@@ -20,6 +21,7 @@
2021
import rcms.fm.resource.qualifiedresource.FunctionManager;
2122
import rcms.fm.fw.parameter.type.StringT;
2223
import rcms.fm.fw.parameter.type.VectorT;
24+
import rcms.fm.app.level1.HCALqgMapper.level1qgMapper;
2325
import rcms.fm.fw.parameter.FunctionManagerParameter;
2426
import rcms.fm.fw.user.UserActionException;
2527

@@ -33,13 +35,15 @@ public class HCALMasker {
3335
protected HCALFunctionManager functionManager = null;
3436
static RCMSLogger logger = null;
3537
public HCALxmlHandler xmlHandler = null;
38+
private level1qgMapper mapper;
3639

37-
public HCALMasker(HCALFunctionManager parentFunctionManager) {
40+
public HCALMasker(HCALFunctionManager parentFunctionManager, level1qgMapper mapper) {
3841
this.logger = new RCMSLogger(HCALFunctionManager.class);
39-
logger.warn("Constructing masker.");
42+
logger.info("Constructing masker.");
4043
this.functionManager = parentFunctionManager;
4144
xmlHandler = new HCALxmlHandler(parentFunctionManager);
42-
logger.warn("Done constructing masker.");
45+
this.mapper = mapper;
46+
logger.info("Done constructing masker.");
4347
}
4448

4549
protected Map<String, Boolean> isEvmTrigCandidate(List<Resource> level2Children) {
@@ -48,7 +52,6 @@ protected Map<String, Boolean> isEvmTrigCandidate(List<Resource> level2Children)
4852
boolean hasAnEventBuilder = false;
4953
boolean hasAnFU = false;
5054
VectorT<StringT> maskedRss = (VectorT<StringT>)functionManager.getHCALparameterSet().get("MASKED_RESOURCES").getValue();
51-
logger.warn(maskedRss.toString());
5255
StringT[] maskedRssArray = maskedRss.toArray(new StringT[maskedRss.size()]);
5356

5457
for (Resource level2resource : level2Children) {
@@ -105,18 +108,16 @@ protected Map<String, Resource> getEvmTrigResources(List<Resource> level2Childre
105108
}
106109

107110
//Add all apps in a masked executives to maskapps list
108-
protected void ignoreMaskedExecutiveApps(List<Resource> level2Children){
111+
protected void ignoreMaskedExecutiveApps(List<Resource> level2Children) throws UserActionException{
109112
VectorT<StringT> maskedRss = (VectorT<StringT>)functionManager.getHCALparameterSet().get("MASKED_RESOURCES").getValue();
110-
StringT[] maskedRssArray = maskedRss.toArray(new StringT[maskedRss.size()]);
111113
if (!maskedRss.isEmpty()){
114+
StringT[] maskedRssArray = maskedRss.toArray(new StringT[maskedRss.size()]);
112115
for(StringT MaskedApp : maskedRssArray){
113116
for(Resource level2resource: level2Children){
114117
if( level2resource.getName().equals(MaskedApp.getString()) && level2resource.getQualifiedResourceType().contains("XdaqExecutive") ){
115-
XdaqExecutiveResource maskedExec = ((XdaqExecutiveResource)level2resource );
116-
logger.info("[HCAL "+ functionManager.FMname+"]: Masking Executive "+MaskedApp.getString()+" and all its apps: "+maskedExec.getApplications().toString());
117-
for( XdaqApplicationResource app : maskedExec.getApplications()){
118-
if (!maskedRss.contains(new StringT(app.getName()) ) ){
119-
maskedRss.add(new StringT(app.getName()));
118+
for (StringT execApp : mapper.getAppsOfExec(level2resource.getName()).getVector()) {
119+
if (! maskedRss.contains(execApp)){
120+
maskedRss.add(execApp);
120121
}
121122
}
122123
}
@@ -177,6 +178,12 @@ protected Map<String, Resource> pickEvmTrig() {
177178
functionManager.theEventHandler.PrintQRnames(level2EvmTrigCandidateList);
178179

179180
//Consider only LV2 FMs with last priority to be EvmTrig (FM with no ConfigPriority will be grouped into this)
181+
try {
182+
setMaskedCrates();
183+
}
184+
catch (UserActionException e) {
185+
logger.error(e.getMessage());
186+
}
180187
for (QualifiedResource level2 : level2EvmTrigCandidateList) {
181188
try {
182189
QualifiedGroup level2group = ((FunctionManager)level2).getQualifiedGroup();
@@ -186,7 +193,12 @@ protected Map<String, Resource> pickEvmTrig() {
186193
List<Resource> level2Children = fullConfig.getChildrenResources();
187194

188195
//Add all masked Executive's app into MASKED_RESOURCES, so that they will not be considered as candidate
189-
ignoreMaskedExecutiveApps(level2Children);
196+
try {
197+
ignoreMaskedExecutiveApps(level2Children);
198+
}
199+
catch (UserActionException ex) {
200+
logger.error("[HCAL " + functionManager.FMname + "]: Got a UserActionException when trying to mask an executive: " + ex.getMessage());
201+
}
190202
Boolean isAcandidate = isEvmTrigCandidate(level2Children).get("isAcandidate");
191203
Boolean isAdummyCandidate = isEvmTrigCandidate(level2Children).get("isAdummyCandidate");
192204
logger.debug("["+functionManager.FMname + "] For this LV2 "+ level2.getName() + " isAcandidate= " + isAcandidate.toString() + " isAdummyCandidate = "+ isAdummyCandidate.toString() );
@@ -377,4 +389,28 @@ else if (functionManager.RunType.equals("global")){
377389
functionManager.getHCALparameterSet().put(new FunctionManagerParameter<VectorT<StringT>>("MASK_SUMMARY", maskedFMsVector));
378390
}
379391
}
392+
393+
public void setMaskedCrates() throws UserActionException {
394+
VectorT<StringT> allMaskedResources = (VectorT<StringT>)functionManager.getHCALparameterSet().get("MASKED_RESOURCES").getValue();
395+
396+
StringT[] maskedResourcesArray = allMaskedResources.toArray(new StringT[allMaskedResources.size()]);
397+
for (StringT maskedResource : maskedResourcesArray) {
398+
if (maskedResource.getString().contains("physicalCrate")) {
399+
try {
400+
if (!Arrays.asList(maskedResourcesArray).contains(maskedResource.getString())) {
401+
allMaskedResources.add(new StringT(mapper.getExecOfCrate(Integer.parseInt(maskedResource.getString().split("_")[1]))));
402+
logger.warn("[HCAL " + functionManager.FMname + "]: Found " + maskedResource + " in masking list, therefore added " + mapper.getExecOfCrate(Integer.parseInt(maskedResource.getString().split("_")[1])) + " to MASKED_RESOURCES");
403+
}
404+
}
405+
catch (NumberFormatException e) {
406+
throw new UserActionException("Could not extract a valid crate number from requested maskedcrate" + e.getMessage());
407+
}
408+
catch (UserActionException e) {
409+
throw new UserActionException("Problem setting the masked crates" + e.getMessage());
410+
}
411+
412+
}
413+
}
414+
functionManager.getHCALparameterSet().put(new FunctionManagerParameter<VectorT<StringT>>("MASKED_RESOURCES", allMaskedResources));
415+
}
380416
}

src/rcms/fm/app/level1/HCALParameters.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ public synchronized void initializeParameters() throws ParameterException {
117117
this.put( new FunctionManagerParameter<VectorT<StringT>> ("MASK_SUMMARY" , new VectorT<StringT>() ) ); // Summary of masked FMs for user understandability
118118
this.put( new FunctionManagerParameter<VectorT<StringT>> ("EMPTY_FMS" , new VectorT<StringT>() ) ); // LV2 FMs without XDAQs
119119
this.put( new FunctionManagerParameter<VectorT<MapT<StringT>> > ("XDAQ_ERR_MSG" , new VectorT<MapT<StringT>>())); // Vector to contain XDAQ app err messages: < <App1:Err>,<App2:Err>,... >
120+
this.put( new FunctionManagerParameter<MapT<MapT<MapT<VectorT<StringT>>>> > ("QG_MAP" , new MapT<MapT<MapT<VectorT<StringT>>>>())); // map of config's QG, see comments in HCALqgMapper
120121
}
121122

122123
public static HCALParameters getInstance() {

src/rcms/fm/app/level1/HCALStateMachineDefinition.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import rcms.fm.fw.parameter.ParameterException;
66
import rcms.fm.fw.parameter.ParameterSet;
77
import rcms.fm.fw.parameter.type.IntegerT;
8+
import rcms.fm.fw.parameter.type.MapT;
89
import rcms.fm.fw.parameter.type.BooleanT;
910
import rcms.fm.fw.parameter.type.StringT;
1011
import rcms.fm.fw.parameter.type.VectorT;

src/rcms/fm/app/level1/HCALlevelOneEventHandler.java

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import org.w3c.dom.NodeList;
2020
import org.w3c.dom.DOMException;
2121

22+
import rcms.fm.app.level1.HCALqgMapper.level1qgMapper;
2223
import rcms.fm.fw.StateEnteredEvent;
2324
import rcms.fm.fw.parameter.CommandParameter;
2425
import rcms.fm.fw.parameter.FunctionManagerParameter;
@@ -71,10 +72,18 @@ public void init() throws rcms.fm.fw.EventHandlerException {
7172

7273
functionManager = (HCALFunctionManager) getUserFunctionManager();
7374
xmlHandler = new HCALxmlHandler(this.functionManager);
74-
masker = new HCALMasker(this.functionManager);
7575

7676
super.init(); // this method calls the base class init and has to be called _after_ the getting of the functionManager
7777

78+
try {
79+
qgMapper = new HCALqgMapper().new level1qgMapper(functionManager.getGroup().getThisResource(), functionManager.getQualifiedGroup());
80+
}
81+
catch (UserActionException e1) {
82+
// TODO Auto-generated catch block
83+
logger.error("[HCAL " + functionManager.FMname + "]: got an error when trying to map the QG: " + e1.getMessage());
84+
}
85+
masker = new HCALMasker(this.functionManager, (level1qgMapper) this.qgMapper);
86+
7887
// Get the CfgCVSBasePath in the userXML
7988
{
8089
String DefaultCfgCVSBasePath = "/nfshome0/hcalcfg/cvs/RevHistory/";
@@ -198,6 +207,9 @@ else if (useResetForRecover.equals("true")) {
198207
if ( ((Element)nodes.item(i)).hasAttribute("maskedFM")){
199208
RunKeySetting.put(new StringT("maskedFM") ,new StringT(nodes.item(i).getAttributes().getNamedItem("maskedFM" ).getNodeValue()));
200209
}
210+
if ( ((Element)nodes.item(i)).hasAttribute("maskedcrates")){
211+
RunKeySetting.put(new StringT("maskedcrates") ,new StringT(nodes.item(i).getAttributes().getNamedItem("maskedcrates" ).getNodeValue()));
212+
}
201213
if ( ((Element)nodes.item(i)).hasAttribute("singlePartitionFM")){
202214
RunKeySetting.put(new StringT("singlePartitionFM") ,new StringT(nodes.item(i).getAttributes().getNamedItem("singlePartitionFM").getNodeValue()));
203215
}
@@ -223,6 +235,7 @@ else if (useResetForRecover.equals("true")) {
223235

224236
functionManager.getHCALparameterSet().put(new FunctionManagerParameter<VectorT<StringT>> ("AVAILABLE_LOCAL_RUNKEYS",LocalRunKeys));
225237
functionManager.getHCALparameterSet().put(new FunctionManagerParameter<MapT<MapT<StringT>>>("LOCAL_RUNKEY_MAP" ,LocalRunKeyMap));
238+
functionManager.getHCALparameterSet().put(new FunctionManagerParameter<MapT<MapT<MapT<VectorT<StringT>>>>>("QG_MAP", (MapT<MapT<MapT<VectorT<StringT>>>>) qgMapper.getMap()));
226239

227240
}
228241
catch (DOMException | UserActionException e) {
@@ -240,6 +253,7 @@ public void initAction(Object obj) throws UserActionException {
240253
if (obj instanceof StateEnteredEvent) {
241254
String MastersnippetSelected = "";
242255
String LocalRunkeySelected = "";
256+
243257
// get the parameters of the command
244258
ParameterSet<CommandParameter> parameterSet = getUserFunctionManager().getLastInput().getParameterSet();
245259

@@ -340,6 +354,7 @@ public void initAction(Object obj) throws UserActionException {
340354

341355
//Fill MASKED_RESOURCES from runkey if not already set by GUI, i.e. global or minidaq run
342356
FillMaskedResources();
357+
//masker.setMaskedCrates();
343358
masker.pickEvmTrig();
344359
masker.setMaskedFMs();
345360

@@ -419,11 +434,13 @@ public void initAction(Object obj) throws UserActionException {
419434
pSet.put(new CommandParameter<IntegerT>("SID", new IntegerT(Sid)));
420435
pSet.put(new CommandParameter<StringT>("GLOBAL_CONF_KEY", new StringT(GlobalConfKey)));
421436

422-
//Pass selected runkey name, mastersnippet file name, runkey map to LV2
437+
//Pass selected runkey name, mastersnippet file name, runkey map, and QG map to LV2
423438
pSet.put(new CommandParameter<StringT>("MASTERSNIPPET_SELECTED", new StringT(MastersnippetSelected)));
424439
pSet.put(new CommandParameter<StringT>("LOCAL_RUNKEY_SELECTED", new StringT(LocalRunkeySelected)));
425440
MapT<MapT<StringT>> LocalRunKeyMap = (MapT<MapT<StringT>>)functionManager.getHCALparameterSet().get("LOCAL_RUNKEY_MAP").getValue();
426441
pSet.put(new CommandParameter<MapT<MapT<StringT>>>("LOCAL_RUNKEY_MAP", LocalRunKeyMap));
442+
MapT<MapT<MapT<VectorT<StringT>>>> qgMap = (MapT<MapT<MapT<VectorT<StringT>>>>)functionManager.getHCALparameterSet().get("QG_MAP").getValue();
443+
pSet.put(new CommandParameter<MapT<MapT<MapT<VectorT<StringT>>>>>("QG_MAP", qgMap));
427444

428445
functionManager.getHCALparameterSet().put(new FunctionManagerParameter<VectorT<StringT>>("MASKED_RESOURCES", MaskedResources));
429446
pSet.put(new CommandParameter<VectorT<StringT>>("MASKED_RESOURCES", MaskedResources));
@@ -1655,6 +1672,7 @@ public void FillMaskedResources(){
16551672
for (String app:maskedapps){
16561673
MaskedResources.add(new StringT(app));
16571674
}
1675+
// XXX JCH what about maskedcrates? should that be used in global?
16581676
}
16591677
logger.info("[HCAL "+functionManager.FMname+" FillMaskedResources: Filled MASKED_RESOURCES from runkey:" + MaskedResources.toString());
16601678
functionManager.getHCALparameterSet().put(new FunctionManagerParameter<VectorT<StringT>>("MASKED_RESOURCES",MaskedResources));
@@ -1663,6 +1681,7 @@ public void FillMaskedResources(){
16631681
}
16641682

16651683
public void checkMaskedappsFormat() throws UserActionException{
1684+
// TODO JCH should something similar be done with maskedcrates?
16661685
StringT runkeyName = (StringT) functionManager.getHCALparameterSet().get("LOCAL_RUNKEY_SELECTED").getValue();
16671686
MapT<MapT<StringT>> LocalRunKeyMap = (MapT<MapT<StringT>>)functionManager.getHCALparameterSet().get("LOCAL_RUNKEY_MAP").getValue();
16681687

src/rcms/fm/app/level1/HCALlevelTwoEventHandler.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import net.hep.cms.xdaqctl.XDAQException;
88
import net.hep.cms.xdaqctl.XDAQTimeoutException;
99
import net.hep.cms.xdaqctl.XDAQMessageException;
10-
10+
import rcms.fm.app.level1.HCALqgMapper.level2qgMapParser;
1111
import rcms.fm.fw.StateEnteredEvent;
1212
import rcms.fm.fw.parameter.CommandParameter;
1313
import rcms.fm.fw.parameter.FunctionManagerParameter;
@@ -53,7 +53,6 @@ public void init() throws rcms.fm.fw.EventHandlerException {
5353
functionManager = (HCALFunctionManager) getUserFunctionManager();
5454
xmlHandler = new HCALxmlHandler(this.functionManager);
5555
super.init();
56-
5756

5857
logger.debug("[HCAL LVL2] init() called: functionManager = " + functionManager );
5958
}
@@ -278,6 +277,15 @@ public void initAction(Object obj) throws UserActionException {
278277
else{
279278
logger.error("[HCAL LVL2 " + functionManager.FMname + "] initAction: Did not receive LOCAL_RUNKEY_MAP during initAction");
280279
}
280+
if( parameterSet.get("QG_MAP") != null){
281+
MapT<MapT<MapT<VectorT<StringT>>>> qgMap = ((MapT<MapT<MapT<VectorT<StringT>>>>)parameterSet.get("QG_MAP").getValue());
282+
logger.info("[HCAL LVL2 " + functionManager.FMname + "] Received QG map: "+qgMap.toString());
283+
functionManager.getParameterSet().put(new FunctionManagerParameter<MapT<MapT<MapT<VectorT<StringT>>>>>("QG_MAP", qgMap));
284+
qgMapper = new HCALqgMapper().new level2qgMapParser(qgMap);
285+
}
286+
else{
287+
logger.error("[HCAL LVL2 " + functionManager.FMname + "] initAction: Did not receive QG_MAP during initAction");
288+
}
281289
// give the RunType to the controlling FM
282290
functionManager.RunType = RunType;
283291
logger.info("[HCAL LVL2 " + functionManager.FMname + "] initAction: We are in " + RunType + " mode ...");

src/rcms/fm/app/level1/HCALlevelTwoFunctionManager.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -88,17 +88,18 @@ public String getSupervisorErrorMessage() {
8888
errMap.put("URI", errAppURI) ;
8989
}
9090
}
91-
// Extract crate number from URI
92-
if (errAppURI.length()>0){
93-
// e.g. URI = http://hcal904daq01.cms904:39100/urn:xdaq-application:lid=53
94-
String errAppPortNumber = errAppURI.getString().split("/")[2].split(":")[1];
95-
// 3 digit in port number = isCrate boolean
96-
if (String.valueOf(errAppPortNumber.charAt(2)).equals("1")){
97-
errAppCrate = new StringT(errAppPortNumber.substring(3));
98-
}
99-
}
91+
//// Extract crate number from URI
92+
//if (errAppURI.length()>0){
93+
// // e.g. URI = http://hcal904daq01.cms904:39100/urn:xdaq-application:lid=53
94+
// String errAppPortNumber = errAppURI.getString().split("/")[2].split(":")[1];
95+
// // 3 digit in port number = isCrate boolean
96+
// if (String.valueOf(errAppPortNumber.charAt(2)).equals("1")){
97+
// errAppCrate = new StringT(errAppPortNumber.substring(3));
98+
// }
99+
//}
100+
errAppCrate = new StringT(theEventHandler.qgMapper.getCrateOfApp(errAppName.getString().replaceAll("(?<!:):(?!:)", "_")));
100101
// Replace instance number with crate number
101-
if (!errAppCrate.equals("")){
102+
if (!errAppCrate.equals("non-crate")){
102103
String[] nameSplit= errAppName.getString().split(":");
103104
String nameOnly = "";
104105
//Remove the last part of ":" split, which is the instance

0 commit comments

Comments
 (0)