23 var _TABLE_BOOL_TYPE_TRUE_COLOR =
"rgb(201, 255, 201)";
24 var _TABLE_BOOL_TYPE_FALSE_COLOR =
"rgb(255, 178, 178)";
27 var stepTimeout = null;
28 var trigTimeout = null;
29 var modifiedList = [];
30 var invalidInput =
false;
31 var syncArray = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
32 var accelMaskArray = [0,0,0,0,0,0,0,0]
33 var tMuxAArray = [[0,0,0,0,0,0,0,0,0]];
34 var tMuxBArray= [[0,0,0,0,0,0,0,0,0]];
35 var logicArray = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
36 var _subsetBasePath =
"FENIMPlusInterfaceConfiguration";
37 var _modifiedTables = [];
38 var writeFEInterfaceStatus =
false;
39 var FEInterfaceStatusValue =
"";
40 var ogBoardState =
"";
41 var fieldList = [[
"NimStatus",
"Status"],
42 [
"NimPlusIP",
"InterfaceIPAddress"],
43 [
"NimPlusPort",
"InterfacePort"],
44 [
"otsHostIP",
"HostIPAddress"],
45 [
"otsHostPort",
"HostPort"],
46 [
"ChAInEn",
"LogicInputChannelA"],
47 [
"ChBInEn",
"LogicInputChannelB"],
48 [
"ChCInEn",
"LogicInputChannelC"],
49 [
"ChDInEn",
"LogicInputChannelD"],
50 [
"useExtClk",
"UseExternalClock"],
51 [
"OutputSourceOutput1",
"TriggerInputChannel1"],
52 [
"OutputSourceOutput2",
"TriggerInputChannel2"],
53 [
"ChAInInv",
"InvertPolarityInputChannelA"],
54 [
"ChBInInv",
"InvertPolarityInputChannelB"],
55 [
"ChCInInv",
"InvertPolarityInputChannelC"],
56 [
"ChDInInv",
"InvertPolarityInputChannelD"],
57 [
"ChADacEl1",
"DACValueChannelA"],
58 [
"ChBDacEl1",
"DACValueChannelB"],
59 [
"ChCDacEl1",
"DACValueChannelC"],
60 [
"ChDDacEl1",
"DACValueChannelD"],
61 [
"ChAOutMux",
"OutputMuxSelectChannelA"],
62 [
"ChBOutMux",
"OutputMuxSelectChannelB"],
63 [
"ChCOutMux",
"OutputMuxSelectChannelC"],
64 [
"ChDOutMux",
"OutputMuxSelectChannelD"],
65 [
"ChAOutInv",
"InvertPolarityOutputChannelA"],
66 [
"ChBOutInv",
"InvertPolarityOutputChannelB"],
67 [
"ChCOutInv",
"InvertPolarityOutputChannelC"],
68 [
"ChDOutInv",
"InvertPolarityOutputChannelD"],
69 [
"Sync1",
"ClockMaskSetup"],
70 [
"AccSync1",
"40MHzClockDelay"],
71 [
"EnableSync0",
"EnableClockMaskTriggerOutputChannel0"],
72 [
"EnableSync1",
"EnableClockMaskTriggerOutputChannel1"],
73 [
"EnableSync2",
"EnableClockMaskTriggerOutputChannel2"],
74 [
"VetoCount",
"TimeVetoTriggerOutputChannel0"],
75 [
"Veto1Count",
"TimeVetoTriggerOutputChannel1"],
76 [
"Veto2Count",
"TimeVetoTriggerOutputChannel2"],
77 [
"VetoSourceOutput0",
"VetoSourceTriggerOutputChannel0"],
78 [
"VetoSourceOutput1",
"VetoSourceTriggerOutputChannel1"],
79 [
"VetoSourceOutput2",
"VetoSourceTriggerOutputChannel2"],
80 [
"PsCount",
"PrescaleTriggerOutputChannel0"],
81 [
"PsCount1",
"PrescaleTriggerOutputChannel1"],
82 [
"PsCount2",
"PrescaleTriggerOutputChannel2"],
83 [
"SL0",
"CoincidenceLogicWord"],
84 [
"bkpEnableA",
"EnableBackPressureNwFmcPta1"],
85 [
"bkpEnableB",
"EnableBackPressureNwFmcPta2"],
86 [
"SGPulseCnt",
"SignalGeneratorPulseCount"],
87 [
"SGHighPer",
"SignalGeneratorHighPeriod"],
88 [
"SGLowPer",
"SignalGeneratorLowPeriod"],
89 [
"sigGenEn",
"SignalGeneratorEnable"],
90 [
"sigGenInv",
"SignalGeneratorInvertPolarity"],
91 [
"ChADelayEl",
"DelayInputChannelA"],
92 [
"ChAWidthEl",
"WidthInputChannelA"],
93 [
"ChBDelayEl",
"DelayInputChannelB"],
94 [
"ChBWidthEl",
"WidthInputChannelB"],
95 [
"ChCDelayEl",
"DelayInputChannelC"],
96 [
"ChCWidthEl",
"WidthInputChannelC"],
97 [
"ChDDelayEl",
"DelayInputChannelD"],
98 [
"ChDWidthEl",
"WidthInputChannelD"],
99 [
"ChSNDelayEl",
"DelayTriggerOutputChannel0"],
100 [
"ChSNWidthEl",
"WidthTriggerOutputChannel0"],
101 [
"ChSCMS1DelayEl",
"DelayTriggerOutputChannel1"],
102 [
"ChSCMS1WidthEl",
"WidthTriggerOutputChannel1"],
103 [
"ChSCMS2DelayEl",
"DelayTriggerOutputChannel2"],
104 [
"ChSCMS2WidthEl",
"WidthTriggerOutputChannel2"],
105 [
"triggerDelaySecs",
"SecondsDelayBeforeStartingTriggers"],
106 [
"ExtClkSel",
"ExternalClockSource"],
107 [
"bkpOutSel0",
"BackpressureTriggerOutputChannel0"],
108 [
"bkpOutSel1",
"BackpressureTriggerOutputChannel1"],
109 [
"bkpOutSel2",
"BackpressureTriggerOutputChannel2"],
110 [
"TMuxB1",
"TriggerMuxSelectionsBankB"],
111 [
"TMuxA1",
"TriggerMuxSelectionsBankA"],
112 [
"triggerFilename",
"TriggerCountAtRunStopFilename"],
113 [
"BurstEn",
"EnableBurstData"],
114 [
"BurstLogicDelay",
"BurstDataLogicSampleDelay"],
115 [
"BurstMuxSel",
"BurstDataMuxSelect"],
116 [
"BurstGateInputCh",
"BurstDataGateInputChannel"]
124 function savePageValues(e) {
125 if(modifiedList.length > 0){
126 if (invalidInput ==
false) {
135 if(writeFEInterfaceStatus ==
false){
136 console.log(
"Don't need to write to FEInterfaceconfiguration, skipping that write.");
137 ConfigurationAPI.getFieldsOfRecords(
138 _subsetBasePath, selUID,
141 setNimFieldValuesForSave,
146 console.log(
"Need to write to FEInterfaceconfiguration...");
147 ConfigurationAPI.getFieldsOfRecords(
148 "FEInterfaceConfiguration", selUID,
151 setFEInterfaceStatusForSave,
159 document.getElementById(
"saveEl").innerHTML =
"Warning! Unable to save, some fields contain invalid values";
160 console.log(
"Warning! Textbox on page has invalid value, aborting save...")
161 console.log(
"Please check the following fields for possible invalid values (some might beSigNorm/ correct)");
162 Debug.log(
"NimPlus Configuration Changes NOT Saved, Invalid value(s) in fields", Debug.HIGH_PRIORITY);
163 console.log(modifiedList);
167 Debug.log(
"Error! No Changes to Save!", Debug.WARN_PRIORITY);
193 function setFEInterfaceStatusForSave(recFields){
194 console.log(
"setFEInterfaceStatusForSave hit");
195 var valsToWrite = [];
199 console.log(
"setFEInterfaceStatusForSave input: \n");
200 console.log(recFields);
202 for (let a of recFields) {
203 if(a.fieldColumnName ==
"Status" && a.fieldRelativePath ==
"") {
205 valsToWrite.push(FEInterfaceStatusValue);
211 ogBoardState = FEInterfaceStatusValue;
212 console.log(objToWrite);
213 console.log(valsToWrite);
215 ConfigurationAPI.setFieldValuesForRecords(
216 "FEInterfaceConfiguration",
220 FEInterfaceToNIMPlusConfigWrite,
226 function FEInterfaceToNIMPlusConfigWrite(newModifiedTables){
227 _modifiedTables.push(newModifiedTables[0])
228 console.log(
"FEInterfaceToNimplus handoff hit");
229 console.log(newModifiedTables[0]);
230 console.log(_modifiedTables);
231 ConfigurationAPI.getFieldsOfRecords(
232 _subsetBasePath, selUID,
235 setNimFieldValuesForSave,
240 function setNimFieldValuesForSave(recFields) {
241 var valsToWrite = [];
245 console.log(
"setNimFields input: \n");
246 console.log(recFields);
252 for (let i of modifiedList) {
253 for (let a of recFields) {
254 if(a.fieldColumnName == i[0]) {
256 valsToWrite.push(i[1]);
257 console.log(
"Object found");
264 console.log(objToWrite);
265 console.log(valsToWrite);
267 ConfigurationAPI.setFieldValuesForRecords(
278 function saveNimTableDialog(newModifiedTables){
280 console.log(newModifiedTables);
281 console.log(_modifiedTables);
282 _modifiedTables = newModifiedTables.splice(0);
283 console.log(_modifiedTables);
284 ConfigurationAPI.saveModifiedTables(
289 function activateNimTables(SavedTable,SavedGroup,SavedAlias){
290 for(let i of SavedGroup) {
291 ConfigurationAPI.activateGroup(i.groupName, i.groupKey,
false)
295 $(
"body").css(
"background-color",
"#43c130");
297 Debug.log(
"NimPlus Configuration Changes Saved to UID " + selUID[0], Debug.INFO_PRIORITY);
298 console.log(
"Page Values Saved");
299 console.log(modifiedList);
300 _modifiedTables = [];
301 writeFEInterfaceStatus =
false;
302 document.getElementById(
"saveEl").innerHTML =
"Save Successful!";
312 function syncMaskCalc(val,a) {
315 var l = syncArray.length;
316 for (var i = 0; i < l; i++) {
317 n |= ((syncArray[i]?1:0) << i)
321 $(
"#triggerSyncWord").val(n);
326 function accelMaskCalc(val,a) {
333 function LogicWordCalc(val,a) {
336 var l = logicArray.length;
337 for (var i = 0; i < l; i++) {
338 n = (n << 1) + (logicArray[i]?1:0);
345 function TMuxAWordCalc(val,a) {
346 tMuxAArray[0][a]=val;
347 return JSON.stringify(tMuxAArray);
351 function TMuxBWordCalc(val,a) {
352 tMuxBArray[0][a]=val;
353 return JSON.stringify(tMuxBArray);
358 function elByID(
id) {
359 e = document.getElementById(
id);
363 function valByID(
id) {
364 e = document.getElementById(
id);
369 function validInput(e) {
370 invalidInput =
false;
374 function invalidValue(e) {
379 function dwValidCheck(firstVal, secondValElId, msgElId) {
380 firstVal = parseInt(firstVal);
381 var secondVal = parseInt(document.getElementById(secondValElId).value);
382 if ((firstVal + secondVal) > 64) {
384 document.getElementById(msgElId).innerHTML =
"Invald Delay/Width Combination! Sum of Delay and Width should be <=64!";
385 $(
"#" + msgElId).css(
"background-color",
"red");
388 document.getElementById(msgElId).innerHTML =
"";
389 $(
"#" + msgElId).css(
"background-color",
"#eee");
390 invalidInput =
false;
396 function addModifiedList(tableVal, tableDat) {
398 $(
"body").css(
"background-color",
"#fcd125")
399 document.getElementById(
"saveEl").innerHTML =
"Unsaved Changes are Present";
401 var modifiedListNames = modifiedList.map(
function(value,index) {
return value[0]; });
403 existsAt = $.inArray(tableVal, modifiedListNames);
406 console.log(existsAt);
407 console.log($.inArray(tableVal, modifiedList[0]));
408 console.log(tableVal);
409 console.log(modifiedList[0]);
410 console.log([tableVal, tableDat]);
411 modifiedList.push([tableVal, tableDat]);
412 console.log(modifiedList);
415 modifiedList[existsAt] = [tableVal,tableDat];
420 function FEInterfaceSetStatus(state){
421 console.log(
"ogBoardState = " + ogBoardState);
422 console.log(
"desired board state = " + state);
424 FEInterfaceStatusValue = state;
425 if(state == ogBoardState)
426 writeFEInterfaceStatus =
false;
428 writeFEInterfaceStatus =
true;
430 console.log(
"writeFEInterfaceStatus = " + writeFEInterfaceStatus)
438 function voltSlider(myValue, VoltElId, StepsElId) {
439 voltVal = (((10000 * ((myValue * (33 / 40950)))) + (((8 - (10000 * ((myValue * (33 / 40950)))) % 8)))) / 10000) - 0.0008;
440 document.getElementById(StepsElId).value = myValue;
441 document.getElementById(VoltElId).value = voltVal.toFixed(4);
442 invalidInput =
false;
447 function voltField(VoltElId, SlideElId, StepElId) {
448 clearTimeout(timeout);
449 timeout = setTimeout(
function () {
450 myValue = VoltElId.value;
451 newValue = (((10000 * myValue) + (((8 - (10000 * myValue) % 8)))) / 10000) - 0.0008;
452 document.getElementById(SlideElId).value = Math.round((40950000 * newValue / 33000));
453 document.getElementById(StepElId).value = Math.round((40950000 * newValue / 33000));
454 VoltElId.value = newValue.toFixed(4);
455 console.log(newValue)
456 console.log(newValue.toFixed(4));
457 invalidInput =
false;
462 function voltSteps(myValue, VoltElId, SlideElId) {
463 voltVal = (((10000 * ((myValue * (33 / 40950)))) + (((8 - (10000 * ((myValue * (33 / 40950)))) % 8)))) / 10000) - 0.0008;
464 document.getElementById(SlideElId).value = (myValue);
465 document.getElementById(VoltElId).value = voltVal.toFixed(4)
466 invalidInput =
false;
469 function triggerSyncWordCalc(val){
470 clearTimeout(trigTimeout);
471 setTimeout(
function () {
472 for(bitCnt=0; bitCnt<=23; bitCnt++){
473 elByID(
"Sync"+(bitCnt+1).toString()).checked=((val>>(bitCnt)) % 2 != 0);
474 syncArray[bitCnt]=((val>>(bitCnt)) % 2 != 0);
485 $(document).ready(
function () {
488 $(
"body").css(
"background-color",
"#6b86ff")
494 $(
"#InChEnCtl").hide();
500 $(
"#DWConfigCtl").hide();
503 $(
"#InMuxCtl").hide();
506 $(
"#OutMuxCtl").hide();
515 $(
"#SyncCtl").hide();
518 $(
"#VetoCtl").hide();
524 $(
"#SelLogCtl").hide();
530 $(
"#SigGenCtl").hide();
533 $(
"#ConnCtl").hide();
536 $(
"#BurstCtl").hide();
540 $(
"#InChEnCtlBtn").click(
function () {
541 $(
"#InChEnCtl").toggle(400);
544 $(
"#DacCtlBtn").click(
function () {
545 $(
"#DacCtl").toggle(400);
548 $(
"#DWConfigBtn").click(
function () {
549 $(
"#DWConfigCtl").toggle(400);
552 $(
"#InMuxCtlBtn").click(
function () {
553 $(
"#InMuxCtl").toggle(400);
556 $(
"#OutMuxCtlBtn").click(
function () {
557 $(
"#OutMuxCtl").toggle(400);
568 $(
"#SyncCtlBtn").click(
function () {
569 $(
"#SyncCtl").toggle(400);
572 $(
"#VetoCtlBtn").click(
function () {
573 $(
"#VetoCtl").toggle(400);
576 $(
"#PsCtlBtn").click(
function () {
577 $(
"#PsCtl").toggle(400);
580 $(
"#SelLogCtlBtn").click(
function () {
581 $(
"#SelLogCtl").toggle(400);
584 $(
"#BkpCtlBtn").click(
function () {
585 $(
"#BkpCtl").toggle(400);
588 $(
"#SigGenCtlBtn").click(
function () {
589 $(
"#SigGenCtl").toggle(400);
592 $(
"#ConnCtlBtn").click(
function () {
593 $(
"#ConnCtl").toggle(400);
596 $(
"#BurstCtlBtn").click(
function () {
597 $(
"#BurstCtl").toggle(400);
601 $(
'.ip_address').mask(
'0ZZ.0ZZ.0ZZ.0ZZ', {translation: {
'Z': {pattern: /[0-9]/, optional:
true}}});
604 $(
'#triggerSyncWord').mask(
'ZZHHHHHHL', {
'translation': {
605 Z: {pattern: /[0x]/, optional:
true},
606 H: {pattern: /[A-Fa-f0-9]/},
607 L: {pattern: /[0-9]/}
612 var spinner = $(
"#triggerSyncWord" ).spinner({
616 $(
"#triggerSyncWord").on(
"spinstop",
function(){
617 triggerSyncWordCalc(this.value);
618 addModifiedList(
'AcceleratorClockMask',this.value);
620 console.log(spinner);
621 console.log(
"jquery ui setup done!")
624 ConfigurationAPI.getSubsetRecords(
638 function getNimUidsForList(nimUids) {
639 if (nimUids.length == 0) {
640 Debug.log(
"No NIMPlus UID's found", Debug.HIGH_PRIORITY);
645 console.log(
"getNimUIDs' Input: \n")
646 console.log(nimUids);
650 console.log(
"first index: " + nimUids[0])
651 $.each(nimUids,
function(val, text) {
652 $(
'#nimUIDSelect').append( $(
'<option></option>').val(text).html(text) )
653 $(
'#nimUIDToCopySelect').append( $(
'<option></option>').val(text).html(text) )
657 selUID = [nimUids[0]];
659 ConfigurationAPI.getFieldsOfRecords(
660 _subsetBasePath, selUID,
669 function getNimFieldsForPage(recFields){
670 console.log(
"recFields: \n");
671 console.log(recFields);
672 ConfigurationAPI.getFieldValuesForRecords(
673 _subsetBasePath, selUID,
679 function getNimValuesForPage(recFields) {
682 console.log(
"getNimValuesForPage input: \n");
683 console.log(recFields);
686 for (let i of fieldList) {
687 for (let a of recFields) {
691 if(a.fieldPath.includes(i[1])) {
693 if(elByID(i[0]).type ==
"checkbox" && !a.fieldPath.includes(
"CoincidenceLogicWord") && !a.fieldPath.includes(
"TriggerClockMask") && !a.fieldPath.includes(
"AcceleratorClockMask"))
695 if(a.fieldValue ==
"Yes" || a.fieldValue ==
"True" || a.fieldValue ==
"On"){
696 elByID(i[0]).checked =
true;
697 console.log(
"checkbox element " + i[0] +
" set to checked = true")
700 elByID(i[0]).checked =
false;
701 console.log(
"checkbox element " + i[0] +
" set to checked = false")
704 else if(a.fieldPath.includes(
"CoincidenceLogicWord")){
705 for(bitCnt=0; bitCnt<=15; bitCnt++){
706 elByID(
"SL"+bitCnt.toString()).checked=((a.fieldValue>>(bitCnt)) % 2 != 0);
707 logicArray[bitCnt]=((a.fieldValue>>(15-bitCnt)) % 2 != 0);
710 console.log(
"Coincidence Logic Word set");
712 else if(a.fieldPath.includes(
"TriggerClockMask")){
713 for(bitCnt=0; bitCnt<=23; bitCnt++){
717 elByID(
"Sync"+(bitCnt+1).toString()).checked=((a.fieldValue>>(bitCnt)) % 2 != 0);
718 syncArray[bitCnt]=((a.fieldValue>>(bitCnt)) % 2 != 0);
720 elByID(
"triggerSyncWord").value = a.fieldValue;
721 console.log(
"Trigger Clock Mask set")
723 else if(a.fieldPath.includes(
"AcceleratorClockMask")){
724 for(bitCnt=0; bitCnt<=7; bitCnt++){
725 elByID(
"AccSync"+(bitCnt+1).toString()).checked=((a.fieldValue>>(bitCnt)) % 2 != 0);
726 accelMaskArray[bitCnt]=((a.fieldValue>>(bitCnt)) % 2 != 0);
728 console.log(
"Accelerator Clock Mask set")
730 else if(a.fieldPath.includes(
"Status")){
731 if(a.fieldValue ==
"Yes" || a.fieldValue ==
"True" || a.fieldValue ==
"On"){
733 elByID(i[0]).value =
"On";
734 console.log(
"NimPlus Status " + i[0] +
" set to On/Enabled")
737 ogBoardState =
"Off";
738 elByID(i[0]).value =
"Off";
739 console.log(
"NimPlus Status " + i[0] +
" set to Off/Disabled")
742 else if(a.fieldPath.includes(
"TriggerMuxSelectionsBankA")){
743 loadMuxArr = JSON.parse(a.fieldValue);
745 elByID(
"TMuxA"+(k+1).toString()).value=loadMuxArr[0][k];
746 tMuxAArray[0][k]=loadMuxArr[0][k];
748 console.log(
"Loaded TMux Bank A with values: " + loadMuxArr );
750 else if(a.fieldPath.includes(
"TriggerMuxSelectionsBankB")){
751 loadMuxArr = JSON.parse(a.fieldValue);
753 elByID(
"TMuxB"+(k+1).toString()).value=loadMuxArr[0][k];
754 tMuxBArray[0][k]=loadMuxArr[0][k];
757 console.log(
"Loaded TMux Bank B with values: " + loadMuxArr);
759 else if(elByID(i[0]).
id==
"ChADacEl1"){
760 voltSteps(a.fieldValue,
"ChADacEl2",
"ChADacEl0")
761 elByID(i[0]).value = a.fieldValue
762 console.log("Set CH A Dac")
764 else if(elByID(i[0]).
id=="ChBDacEl1"){
765 voltSteps(a.fieldValue,
"ChBDacEl2",
"ChBDacEl0")
766 elByID(i[0]).value = a.fieldValue
767 console.log("Set CH B Dac")
769 else if(elByID(i[0]).
id=="ChCDacEl1"){
770 voltSteps(a.fieldValue,
"ChCDacEl2",
"ChCDacEl0")
771 elByID(i[0]).value = a.fieldValue
772 console.log("Set CH C Dac")
774 else if(elByID(i[0]).
id=="ChDDacEl1"){
775 voltSteps(a.fieldValue,
"ChDDacEl2",
"ChDDacEl0")
776 elByID(i[0]).value = a.fieldValue
777 console.log("Set CH D Dac")
780 elByID(i[0]).value = a.fieldValue;
781 console.log(
"set element " + i[0] +
" to value " + a.fieldValue +
" from " + a.fieldPath)
785 console.log(
"\n!!!_-_-_WARNING_-_-_!!!\n");
786 console.log(
"Exception occured while trying to set an element supposedly named " + i[0] +
" to the value of " + a.fieldValue +
" from the field " + a.fieldPath);
787 console.log(
"Incoming exception data...\n");
789 console.log(
"\n!!!_-_-_END WARNING_-_-_!!!\n");
793 else if(a.fieldPath.includes(
"EnableExpertWebappFeatures")){
794 if(a.fieldValue ==
"Yes"){
795 $(
"#SigGenBox").show()
798 $(
"#BurstBox").show()
801 $(
"#SigGenBox").hide()
804 $(
"#BurstBox").hide()
822 function getNimValuesOnUIDSelect(selValue) {
826 ConfigurationAPI.getFieldsOfRecords(
827 _subsetBasePath, selUID,