diff --git a/deploy/packaging/debian/rfxdevices.noarch b/deploy/packaging/debian/rfxdevices.noarch index d89764a6b7..30645a0a72 100644 --- a/deploy/packaging/debian/rfxdevices.noarch +++ b/deploy/packaging/debian/rfxdevices.noarch @@ -72,6 +72,7 @@ ./usr/local/mdsplus/pydevices/RfxDevices/MARTE2_SWTRIG.py ./usr/local/mdsplus/pydevices/RfxDevices/MARTE2_UDP_RECEIVER.py ./usr/local/mdsplus/pydevices/RfxDevices/MARTE2_UDP_SENDER.py +./usr/local/mdsplus/pydevices/RfxDevices/MARTE2_WRTDTIMER.py ./usr/local/mdsplus/pydevices/RfxDevices/MARTE_BREAKDOWN.py ./usr/local/mdsplus/pydevices/RfxDevices/MARTE_COMMON.py ./usr/local/mdsplus/pydevices/RfxDevices/MARTE_CONFIG.py diff --git a/deploy/packaging/redhat/rfxdevices.noarch b/deploy/packaging/redhat/rfxdevices.noarch index 48a1126849..725f4cfaaf 100644 --- a/deploy/packaging/redhat/rfxdevices.noarch +++ b/deploy/packaging/redhat/rfxdevices.noarch @@ -73,6 +73,7 @@ ./usr/local/mdsplus/pydevices/RfxDevices/MARTE2_SWTRIG.py ./usr/local/mdsplus/pydevices/RfxDevices/MARTE2_UDP_RECEIVER.py ./usr/local/mdsplus/pydevices/RfxDevices/MARTE2_UDP_SENDER.py +./usr/local/mdsplus/pydevices/RfxDevices/MARTE2_WRTDTIMER.py ./usr/local/mdsplus/pydevices/RfxDevices/MARTE_BREAKDOWN.py ./usr/local/mdsplus/pydevices/RfxDevices/MARTE_COMMON.py ./usr/local/mdsplus/pydevices/RfxDevices/MARTE_CONFIG.py diff --git a/java/jdevices/src/main/java/MARTE2_SIMULINK_GENERICSetup.java b/java/jdevices/src/main/java/MARTE2_SIMULINK_GENERICSetup.java index 71611c06b8..6dfa1584c0 100644 --- a/java/jdevices/src/main/java/MARTE2_SIMULINK_GENERICSetup.java +++ b/java/jdevices/src/main/java/MARTE2_SIMULINK_GENERICSetup.java @@ -174,8 +174,11 @@ private void initComponents() { deviceField4 = new DeviceField(); jButton1 = new javax.swing.JButton(); deviceChoice17 = new DeviceChoice(); + jPanel47 = new javax.swing.JPanel(); + deviceField77 = new DeviceField(); + deviceField78 = new DeviceField(); - setDeviceProvider("spilds:8100"); + setDeviceProvider("localhost:8100"); setDeviceTitle("MARTe2 Simulink Generic device"); setDeviceType("MARTE2_SIMULINK_GENERIC"); setHeight(400); @@ -874,7 +877,7 @@ private void initComponents() { getContentPane().add(jTabbedPane1, java.awt.BorderLayout.CENTER); - jPanel1.setLayout(new java.awt.GridLayout(2, 1)); + jPanel1.setLayout(new java.awt.GridLayout(3, 0)); deviceField1.setIdentifier(""); deviceField1.setLabelString("Timebase:"); @@ -920,6 +923,20 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { jPanel1.add(jPanel3); + deviceField77.setIdentifier(""); + deviceField77.setLabelString("MDS write trigger:"); + deviceField77.setNumCols(30); + deviceField77.setOffsetNid(96); + jPanel47.add(deviceField77); + + deviceField78.setIdentifier(""); + deviceField78.setLabelString("Post trig. Samples: "); + deviceField78.setNumCols(6); + deviceField78.setOffsetNid(98); + jPanel47.add(deviceField78); + + jPanel1.add(jPanel47); + getContentPane().add(jPanel1, java.awt.BorderLayout.PAGE_START); }// //GEN-END:initComponents @@ -1033,6 +1050,8 @@ private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRS private DeviceField deviceField74; private DeviceField deviceField75; private DeviceField deviceField76; + private DeviceField deviceField77; + private DeviceField deviceField78; private DeviceField deviceField8; private DeviceField deviceField9; private javax.swing.JButton jButton1; @@ -1077,6 +1096,7 @@ private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRS private javax.swing.JPanel jPanel44; private javax.swing.JPanel jPanel45; private javax.swing.JPanel jPanel46; + private javax.swing.JPanel jPanel47; private javax.swing.JPanel jPanel5; private javax.swing.JPanel jPanel6; private javax.swing.JPanel jPanel7; diff --git a/java/jdevices/src/main/java/MARTE2_WRTDTIMERSetup.java b/java/jdevices/src/main/java/MARTE2_WRTDTIMERSetup.java new file mode 100644 index 0000000000..5572990540 --- /dev/null +++ b/java/jdevices/src/main/java/MARTE2_WRTDTIMERSetup.java @@ -0,0 +1,137 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + +/** + * + * @author mdsplus + */ +public class MARTE2_WRTDTIMERSetup extends DeviceSetup { + + /** + * Creates new form MARTE2_WRTDTIMERSetup + */ + public MARTE2_WRTDTIMERSetup() { + initComponents(); + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + deviceButtons1 = new DeviceButtons(); + jPanel2 = new javax.swing.JPanel(); + jPanel3 = new javax.swing.JPanel(); + deviceChoice1 = new DeviceChoice(); + deviceField1 = new DeviceField(); + deviceField5 = new DeviceField(); + jPanel4 = new javax.swing.JPanel(); + deviceField2 = new DeviceField(); + deviceField3 = new DeviceField(); + deviceField4 = new DeviceField(); + jPanel5 = new javax.swing.JPanel(); + deviceField6 = new DeviceField(); + deviceField7 = new DeviceField(); + deviceField8 = new DeviceField(); + jPanel1 = new javax.swing.JPanel(); + + setDeviceProvider("localhost:8100"); + setDeviceTitle("WRTD Timer "); + setDeviceType("MARTE2_WRTDTIMER"); + setHeight(200); + setWidth(700); + getContentPane().add(deviceButtons1, java.awt.BorderLayout.PAGE_END); + + jPanel2.setLayout(new java.awt.GridLayout(3, 0)); + + deviceChoice1.setChoiceItems(new String[] {"CLOCK_TAI", "CLOCK_REALTIME", "CLOCK_MONOTONIC", "CLOCK_PTP"}); + deviceChoice1.setIdentifier(""); + deviceChoice1.setLabelString("Clock Mode: "); + deviceChoice1.setOffsetNid(7); + deviceChoice1.setUpdateIdentifier(""); + jPanel3.add(deviceChoice1); + + deviceField1.setIdentifier(""); + deviceField1.setLabelString("Event Name (reg.expr.):"); + deviceField1.setOffsetNid(16); + deviceField1.setTextOnly(true); + jPanel3.add(deviceField1); + + deviceField5.setIdentifier(""); + deviceField5.setLabelString("CPU Mask: "); + deviceField5.setNumCols(4); + deviceField5.setOffsetNid(10); + jPanel3.add(deviceField5); + + jPanel2.add(jPanel3); + + deviceField2.setIdentifier(""); + deviceField2.setLabelString("UDP Port:"); + deviceField2.setNumCols(5); + deviceField2.setOffsetNid(13); + jPanel4.add(deviceField2); + + deviceField3.setIdentifier(""); + deviceField3.setLabelString("Multicast Group"); + deviceField3.setOffsetNid(19); + deviceField3.setTextOnly(true); + jPanel4.add(deviceField3); + + deviceField4.setIdentifier(""); + deviceField4.setLabelString("Leap Seconds: "); + deviceField4.setNumCols(4); + deviceField4.setOffsetNid(22); + jPanel4.add(deviceField4); + + jPanel2.add(jPanel4); + + deviceField6.setIdentifier(""); + deviceField6.setLabelString("Perios(s): "); + deviceField6.setNumCols(6); + deviceField6.setOffsetNid(31); + jPanel5.add(deviceField6); + + deviceField7.setIdentifier(""); + deviceField7.setLabelString("Delay(s):"); + deviceField7.setNumCols(6); + deviceField7.setOffsetNid(25); + jPanel5.add(deviceField7); + + deviceField8.setIdentifier(""); + deviceField8.setLabelString("Phase(s): "); + deviceField8.setNumCols(6); + deviceField8.setOffsetNid(28); + jPanel5.add(deviceField8); + + jPanel2.add(jPanel5); + + getContentPane().add(jPanel2, java.awt.BorderLayout.PAGE_START); + getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER); + }// //GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private DeviceButtons deviceButtons1; + private DeviceChoice deviceChoice1; + private DeviceField deviceField1; + private DeviceField deviceField2; + private DeviceField deviceField3; + private DeviceField deviceField4; + private DeviceField deviceField5; + private DeviceField deviceField6; + private DeviceField deviceField7; + private DeviceField deviceField8; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel3; + private javax.swing.JPanel jPanel4; + private javax.swing.JPanel jPanel5; + // End of variables declaration//GEN-END:variables +} diff --git a/java/jdevices/src/main/resources/MARTE2_SIMULINK_GENERICSetup.form b/java/jdevices/src/main/resources/MARTE2_SIMULINK_GENERICSetup.form index 89bf4e3ca0..7f34cf2c6e 100644 --- a/java/jdevices/src/main/resources/MARTE2_SIMULINK_GENERICSetup.form +++ b/java/jdevices/src/main/resources/MARTE2_SIMULINK_GENERICSetup.form @@ -2,7 +2,7 @@
- + @@ -1438,8 +1438,8 @@ - - + + @@ -1512,6 +1512,28 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/java/jdevices/src/main/resources/MARTE2_WRTDTIMERSetup.form b/java/jdevices/src/main/resources/MARTE2_WRTDTIMERSetup.form new file mode 100644 index 0000000000..bede91d0b3 --- /dev/null +++ b/java/jdevices/src/main/resources/MARTE2_WRTDTIMERSetup.form @@ -0,0 +1,158 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pydevices/RfxDevices/MARTE2_COMPONENT.py b/pydevices/RfxDevices/MARTE2_COMPONENT.py index e88648e341..129a706071 100644 --- a/pydevices/RfxDevices/MARTE2_COMPONENT.py +++ b/pydevices/RfxDevices/MARTE2_COMPONENT.py @@ -1077,9 +1077,10 @@ def getMarteGamInfo(self, threadMap, gams, dataSources, gamList, typeDicts): nonGamInputNodes.append( {'expr': inputDict['value'], 'dimensions': inputDict['dimensions'], 'name': signalName, 'col_order': inputDict['col_order']}) gamText += ' '+signalName+' = {\n' - gamText += ' DataSource = '+gamName+'_TreeInput\n' + gamText += ' DataSource = '+gamName+'_TreeInDDB\n' signalDict['name'] = signalName - signalDict['datasource'] = gamName+'_TreeInput_Logger' + #GAB 2022 signalDict['datasource'] = gamName+'_TreeInput_Logger' + signalDict['datasource'] = gamName+'_TreeInput_LoggerDDB' else: gamText += ' '+signalGamName+' = {\n' if isInputStructField: @@ -1179,6 +1180,8 @@ def getMarteGamInfo(self, threadMap, gams, dataSources, gamList, typeDicts): dataSourceText += ' }\n' dataSources.append(dataSourceText) + if len(nonGamInputNodes) > 0: + gamList.append(gamName+'_TreeIn') gamList.append(gamName) ######################################################### Output Signals outputSignals = [] # For debug printout @@ -1317,6 +1320,8 @@ def getMarteGamInfo(self, threadMap, gams, dataSources, gamList, typeDicts): dataSourceText += ' }\n' # Time Management dataSourceText += ' Time = {\n' + dataSourceText += ' DiscontinuityFactor = 1\n' + dataSourceText += ' Type = int32\n' dataSourceText += ' NodeName = "' + \ configDict['outTimeNid'].getFullPath()+'"\n' # keep into account possibl sample information for that GAM @@ -1343,6 +1348,7 @@ def getMarteGamInfo(self, threadMap, gams, dataSources, gamList, typeDicts): outputDict['value_nid'].getFullPath()+'"\n' dataSourceText += ' Period = ' + \ str(period/currSamples)+'\n' + dataSourceText += ' DiscontinuityFactor = 1\n' dataSourceText += ' MakeSegmentAfterNWrites = ' + \ str(outputDict['seg_len'])+'\n' dataSourceText += ' AutomaticSegmentation = 0\n' @@ -1412,7 +1418,7 @@ def getMarteGamInfo(self, threadMap, gams, dataSources, gamList, typeDicts): nonGamInputNodes.append({'expr': outputTrigger.decompile( ), 'dimensions': 0, 'name': 'Trigger', 'col_order': False}) gamText += ' '+'Trigger'+' = {\n' - gamText += ' DataSource = '+gamName+'_TreeInput\n' + gamText += ' DataSource = '+gamName+'_TreeInDDB\n' gamText += ' Type = uint8\n' gamText += ' }\n' # end Trigger Management @@ -1420,7 +1426,8 @@ def getMarteGamInfo(self, threadMap, gams, dataSources, gamList, typeDicts): # Time signal management gamText += ' Time = {\n' gamText += ' DataSource = ' + timerDDB+'\n' - gamText += ' Type = uint32\n' +# gamText += ' Type = uint32\n' GAB2022 + gamText += ' Type = int32\n' gamText += ' }\n' # Other output signals # first non struct outputs @@ -1452,7 +1459,8 @@ def getMarteGamInfo(self, threadMap, gams, dataSources, gamList, typeDicts): # Time signal gamText += ' Time = {\n' gamText += ' DataSource = '+gamName+'_TreeOutput\n' - gamText += ' Type = uint32\n' +# gamText += ' Type = uint32\n' GAB2022 + gamText += ' Type = int32\n' gamText += ' }\n' # Other signals for outputDict in outputDicts: @@ -1716,7 +1724,8 @@ def getMarteGamInfo(self, threadMap, gams, dataSources, gamList, typeDicts): nonGamInputNodes.append( {'expr': fieldDict['value'], 'dimensions': fieldDict['dimensions'], 'name': signalName, 'col_order': fieldDict['col_order']}) gamText += ' '+signalName+' = {\n' - gamText += ' DataSource = '+gamName+'_TreeInput\n' +# GAB 2022 gamText += ' DataSource = '+gamName+'_TreeInput\n' + gamText += ' DataSource = '+gamName+'_TreeInDDB\n' else: gamText += ' '+signalGamName+' = {\n' if isInputStructField: @@ -1780,68 +1789,59 @@ def getMarteGamInfo(self, threadMap, gams, dataSources, gamList, typeDicts): # endif needInputBusConversion # There are input references to tree nodes, we need to build a MdsReader DataSource named _TreeInput + # GAB 2022 here are input references to tree nodes, we need to build a MDSReaderGAM instance named _TreeInput and a DDB + # named _TreeInput_DDB if len(nonGamInputNodes) > 0: - # if debugEnabled, we need to write TWO instances of MDSReaderNS (_TreeInput and _TreeInput_Debug) + # if debugEnabled, we need to write TWO instances of MDSReaderGAB (_TreeInput and _TreeInput_Debug) treeInputExtensions = [] - treeInputExtensions.append('_TreeInput') + treeInputExtensions.append('_TreeIn') if debugEnabled: - treeInputExtensions.append('_TreeInput_Logger') + treeInputExtensions.append('_TreeIn_Logger') for treeInputExtension in treeInputExtensions: - #dataSourceText = ' +'+gamName+'_TreeInput = {\n' - dataSourceText = ' +'+gamName+treeInputExtension + ' = {\n' - dataSourceText += ' Class = MDSReaderNS\n' - dataSourceText += ' UseColumnOrder = 0\n' - dataSourceText += ' TreeName = "'+self.getTree().name+'"\n' - dataSourceText += ' ShotNumber = ' + \ - str(self.getTree().shot)+'\n' - currTimebase = self.getNode('timebase').evaluate() - if isinstance(currTimebase, Range): - startTime = currTimebase.begin.data() - period = currTimebase.delta.data() - else: - currTimebase = currTimebase.data() - startTime = currTimebase[0] - period = currTimebase[1] - currTimebase[0] - frequency = 1./period + dataSourceText = ' +'+gamName+treeInputExtension+'DDB = {\n' + dataSourceText += ' Class = GAMDataSource\n' + dataSourceText += ' }\n' + dataSources.append(dataSourceText) - dataSourceText += ' StartTime = '+str(startTime)+'\n' - dataSourceText += ' Frequency = ' + \ - str(round(frequency, 4))+'\n' - dataSourceText += ' Signals = { \n' + mdsReaderText = ' +'+gamName+treeInputExtension + ' = {\n' + mdsReaderText += ' Class = MDSReaderGAM\n' + mdsReaderText += ' TreeName = "'+self.getTree().name+'"\n' + mdsReaderText += ' ShotNumber = ' + \ + str(self.getTree().shot)+'\n' + mdsReaderText += ' InputSignals = { \n' + mdsReaderText += ' Time = {\n' + mdsReaderText += ' DataSource = '+timerDDB + '\n' + mdsReaderText += ' } \n' + mdsReaderText += ' } \n' + mdsReaderText += ' OutputSignals = { \n' for nodeDict in nonGamInputNodes: - dataSourceText += ' '+nodeDict['name']+' = {\n' + mdsReaderText += ' '+nodeDict['name']+' = {\n' + mdsReaderText += ' DataSource = '+gamName+treeInputExtension+'DDB\n' valExpr = nodeDict['expr'] if isinstance(valExpr, TreeNode): -# valExpr = valExpr.getPath() valExpr = str(valExpr) else: valExpr = str(valExpr) valExpr = valExpr.replace('"', "'") - dataSourceText += ' DataExpr = "'+valExpr+'"\n' - dataSourceText += ' TimebaseExpr = "dim_of(' + \ + mdsReaderText += ' DataExpr = "'+valExpr+'"\n' + mdsReaderText += ' TimebaseExpr = "dim_of(' + \ valExpr+')"\n' - numberOfElements = 1 if not (np.isscalar(nodeDict['dimensions'])): for currDim in nodeDict['dimensions']: numberOfElements *= currDim - dataSourceText += ' NumberOfElements = ' + \ + mdsReaderText += ' NumberOfElements = ' + \ str(numberOfElements)+'\n' if nodeDict['col_order']: - dataSourceText += ' UseColumnOrder = 1\n' + mdsReaderText += ' UseColumnOrder = 1\n' else: - dataSourceText += ' UseColumnOrder = 0\n' - dataSourceText += ' DataManagement = 1\n' - dataSourceText += ' }\n' - dataSourceText += ' timebase = {\n' - dataSourceText += ' NumberOfElements = 1\n' - dataSourceText += ' Type = uint64\n' - dataSourceText += ' }\n' - dataSourceText += ' }\n' - dataSourceText += ' }\n' - dataSources.append(dataSourceText) - - # Some outputs are connected to devices on separate synchronized threads + mdsReaderText += ' UseColumnOrder = 0\n' + mdsReaderText += ' DataManagement = 1\n' + mdsReaderText += ' }\n' + mdsReaderText += ' }\n' + mdsReaderText += ' }\n' + gams.append(mdsReaderText) +# Some outputs are connected to devices on separate synchronized threads if len(synchThreadSignals) > 0: dataSourceText = ' +'+gamName+'_Output_Synch = {\n' dataSourceText += ' Class = RealTimeThreadSynchronisation\n' @@ -2256,6 +2256,8 @@ def getMarteInputInfo(self, threadMap, gams, dataSources, gamList, isSynch): # If the Input device is not synchronising, store time in outputs:time if not isSynch: dataSourceText += ' Time = {\n' + dataSourceText += ' DiscontinuityFactor = 1\n' + dataSourceText += ' Type = int32\n' dataSourceText += ' NodeName = "' + \ configDict['outTimeNid'].getFullPath()+'"\n' # We must keep into account the number of samples in an input device @@ -2273,6 +2275,7 @@ def getMarteInputInfo(self, threadMap, gams, dataSources, gamList, isSynch): for outputDict in outputDicts: if outputDict['seg_len'] > 0: dataSourceText += ' '+outputDict['name']+' = {\n' + dataSourceText += ' DiscontinuityFactor = 1\n' dataSourceText += ' NodeName = "' + \ outputDict['value_nid'].getFullPath()+'"\n' # We must keep into account the number of samples in an input device @@ -2299,7 +2302,8 @@ def getMarteInputInfo(self, threadMap, gams, dataSources, gamList, isSynch): dataSourceText += ' Class = GAMDataSource\n' dataSourceText += ' }\n' dataSources.append(dataSourceText) - + if len(nonGamInputNodes) > 0: + gamList.append(dataSourceName+'_TreeIn') gamList.append(dataSourceName+'_DDBOutIOGAM') gamText = ' +'+dataSourceName+'_DDBOutIOGAM = {\n' gamText += ' Class = IOGAM\n' @@ -2398,7 +2402,8 @@ def getMarteInputInfo(self, threadMap, gams, dataSources, gamList, isSynch): nonGamInputNodes.append({'expr': outputTrigger.decompile( ), 'dimensions': 0, 'name': 'Trigger', 'col_order': False}) gamText += ' '+'Trigger'+' = {\n' - gamText += ' DataSource = '+dataSourceName+'_TreeInput\n' +# GAB2022 gamText += ' DataSource = '+dataSourceName+'_TreeInput\n' + gamText += ' DataSource = '+dataSourceName+'_TreeInDDB\n' gamText += ' Type = uint8\n' gamText += ' }\n' # end Trigger Management @@ -2408,6 +2413,7 @@ def getMarteInputInfo(self, threadMap, gams, dataSources, gamList, isSynch): gamText += ' Time = {\n' # GABRIELE SEPT 2020 gamText += ' DataSource = '+dataSourceName+'_Timer_DDB' gamText += ' DataSource = '+timerDDB + gamText += ' Type = int32\n' gamText += ' }\n' # Other signals @@ -2429,6 +2435,7 @@ def getMarteInputInfo(self, threadMap, gams, dataSources, gamList, isSynch): # If the Input device is not synchronising, transfer also time towards MdsWriter if not isSynch: gamText += ' Time = {\n' + gamText += ' Type = int32\n' gamText += ' DataSource = '+dataSourceName + \ '_TreeOutput' # GABRIELE SEPT 2020 gamText += ' }\n' @@ -2459,56 +2466,48 @@ def getMarteInputInfo(self, threadMap, gams, dataSources, gamList, isSynch): gams.append(gamText) # endif configDict['storeSignals'] - +# GAB 2022 if len(nonGamInputNodes) > 0: # For input devices this happens only if a trigger signal for MdsWriter is derived from a waveform stored in the tree - dataSourceText = ' +'+dataSourceName+'_TreeInput = {\n' - dataSourceText += ' Class = MDSReaderNS\n' - dataSourceText += ' UseColumnOrder = 0\n' - dataSourceText += ' TreeName = "'+self.getTree().name+'"\n' - dataSourceText += ' ShotNumber = '+str(self.getTree().shot)+'\n' - currTimebase = self.getNode('timebase').evaluate() - if isinstance(currTimebase, Range): - startTime = currTimebase.begin.data() - period = currTimebase.delta.data() - else: - currTimebase = currTimebase.data() - startTime = currTimebase[0] - period = currTimebase[1] - currTimebase[0] - frequency = 1./period + dataSourceText = ' +'+DataSourceName+'_TreeInDDB = {\n' + dataSourceText += ' Class = GAMDataSource\n' + dataSourceText += ' }\n' + dataSources.append(dataSourceText) - dataSourceText += ' StartTime = '+str(startTime)+'\n' - dataSourceText += ' Frequency = '+str(round(frequency, 4))+'\n' - dataSourceText += ' Signals = { \n' + mdsReaderText = ' +'+dataSourceName+ '_TreeIn = {\n' + mdsReaderText += ' Class = MDSReaderGAM\n' + mdsReaderText += ' TreeName = "'+self.getTree().name+'"\n' + mdsReaderText += ' ShotNumber = '+str(self.getTree().shot)+'\n' + mdsReaderText += ' InputSignals = { \n' + mdsReaderText += ' Time = {\n' + mdsReaderText += ' DataSource = '+timerDDB + '\n' + mdsReaderText += ' } \n' + mdsReaderText += ' } \n' + mdsReaderText += ' OutputSignals = { \n' for nodeDict in nonGamInputNodes: - dataSourceText += ' '+nodeDict['name']+' = {\n' + mdsReaderText += ' '+nodeDict['name']+' = {\n' + mdsReaderText += ' DataSource = '+dataSourceName+ '_TreeInDDB\n' valExpr = nodeDict['expr'] if isinstance(valExpr, TreeNode): valExpr = valExpr.getFullPath() valExpr = valExpr.replace('"', "'") - dataSourceText += ' DataExpr = "'+valExpr+'"\n' - dataSourceText += ' TimebaseExpr = "dim_of(' + \ + mdsReaderText += ' DataExpr = "'+valExpr+'"\n' + mdsReaderText += ' TimebaseExpr = "dim_of(' + \ valExpr+')"\n' numberOfElements = 1 if not (np.isscalar(nodeDict['dimensions'])): for currDim in nodeDict['dimensions']: numberOfElements *= currDim - dataSourceText += ' NumberOfElements = ' + \ + mdsReaderText += ' NumberOfElements = ' + \ str(numberOfElements)+'\n' if nodeDict['col_order']: - dataSourceText += ' UseColumnOrder = 1\n' + mdsReaderText += ' UseColumnOrder = 1\n' else: - dataSourceText += ' UseColumnOrder = 0\n' - dataSourceText += ' DataManagement = 1\n' - dataSourceText += ' }\n' - dataSourceText += ' timebase = {\n' - dataSourceText += ' NumberOfElements = 1\n' - dataSourceText += ' Type = uint64\n' - dataSourceText += ' }\n' - dataSourceText += ' }\n' - dataSourceText += ' }\n' - dataSources.append(dataSourceText) - - # Some outputs are connected to devices on separate synchronized theads + mdsReaderText += ' UseColumnOrder = 0\n' + mdsReaderText += ' DataManagement = 1\n' + mdsReaderText += ' }\n' + mdsReaderText += ' }\n' + gams.append(mdsReaderText) + # Some outputs are connected to devices on separate synchronized theads if len(synchThreadSignals) > 0: dataSourceText = ' +'+dataSourceName+'_Output_Synch = {\n' dataSourceText += ' Class = RealTimeThreadSynchronisation\n' @@ -2516,7 +2515,7 @@ def getMarteInputInfo(self, threadMap, gams, dataSources, gamList, isSynch): dataSourceText += ' }\n' dataSources.append(dataSourceText) - gamList.append(dataSourceName+'_Output_Synch_IOGAM') + gamText = ' +'+dataSourceName+'_Output_Synch_IOGAM = {\n' @@ -2711,7 +2710,6 @@ def getMarteOutputInfo(self, threadMap, gams, dataSources, gamList): return 0 #Head and parameters - gamList.append(dataSourceName+'_IOGAM') gamText = ' +'+dataSourceName+'_IOGAM = {\n' # gamText += ' Class = IOGAM\n' #NOTE: default behavior for Output is different from that of GAM. Here a single sample is picked when subsampling is defined (syncDiv > 1) @@ -2770,7 +2768,8 @@ def getMarteOutputInfo(self, threadMap, gams, dataSources, gamList): nonGamInputNodes.append( {'expr': inputDict['value'], 'dimensions': inputDict['dimensions'], 'name': signalName, 'col_order': inputDict['col_order']}) gamText += ' '+signalName+' = {\n' - gamText += ' DataSource = '+dataSourceName+'_TreeInput\n' +# GAB 2022 gamText += ' DataSource = '+dataSourceName+'_TreeInput\n' + gamText += ' DataSource = '+dataSourceName+'_TreeInDDB\n' if 'type' in inputDict: gamText += ' Type = '+inputDict['type']+'\n' else: @@ -2854,58 +2853,51 @@ def getMarteOutputInfo(self, threadMap, gams, dataSources, gamList): gamText += ' }\n' gams.append(gamText) + if len(nonGamInputNodes) > 0: #GAB 2022 + gamList.append(dataSourceName+'_TreeIn') + gamList.append(dataSourceName+'_IOGAM') + # There are input references to tree nodes, we need to build a MdsReader DataSource named _TreeInput if len(nonGamInputNodes) > 0: - dataSourceText = ' +'+dataSourceName+'_TreeInput = {\n' - dataSourceText += ' Class = MDSReaderNS\n' - dataSourceText += ' UseColumnOrder = 0\n' - dataSourceText += ' TreeName = "'+self.getTree().name+'"\n' - dataSourceText += ' ShotNumber = '+str(self.getTree().shot)+'\n' - currTimebase = self.getNode('timebase').evaluate() - if isinstance(currTimebase, Range): - startTime = currTimebase.begin.data() - period = currTimebase.delta.data() - else: - currTimebase = currTimebase.data() - startTime = currTimebase[0] - period = currTimebase[1] - currTimebase[0] - frequency = 1./period + dataSourceText = ' +'+DataSourceName+'_TreeInDDB = {\n' + dataSourceText += ' Class = GAMDataSource\n' + dataSourceText += ' }\n' + dataSources.append(dataSourceText) - dataSourceText += ' StartTime = '+str(startTime)+'\n' -# dataSourceText += ' Frequency = '+str(int(round(frequency)))+'\n' - dataSourceText += ' Frequency = '+str(round(frequency, 4))+'\n' - dataSourceText += ' Signals = { \n' + mdsReaderText = ' +'+dataSourceName+ '_TreeIn = {\n' + mdsReaderText += ' Class = MDSReaderGAM\n' + mdsReaderText += ' TreeName = "'+self.getTree().name+'"\n' + mdsReaderText += ' ShotNumber = '+str(self.getTree().shot)+'\n' + mdsReaderText += ' InputSignals = { \n' + mdsReaderText += ' Time = {\n' + mdsReaderText += ' DataSource = '+timerDDB + '\n' + mdsReaderText += ' } \n' + mdsReaderText += ' } \n' + mdsReaderText += ' OutputSignals = { \n' for nodeDict in nonGamInputNodes: - dataSourceText += ' '+nodeDict['name']+' = {\n' + mdsReaderText += ' '+nodeDict['name']+' = {\n' + mdsReaderText += ' DataSource = '+dataSourceName+ '_TreeInDDB\n' valExpr = nodeDict['expr'] if isinstance(valExpr, TreeNode): valExpr = valExpr.getFullPath() - if isinstance(valExpr, str): - valExpr = valExpr.replace('"', "'") - dataSourceText += ' DataExpr = "'+str(valExpr)+'"\n' - dataSourceText += ' TimebaseExpr = "dim_of(' + \ - str(valExpr)+')"\n' + valExpr = valExpr.replace('"', "'") + mdsReaderText += ' DataExpr = "'+valExpr+'"\n' + mdsReaderText += ' TimebaseExpr = "dim_of(' + \ + valExpr+')"\n' numberOfElements = 1 if not (np.isscalar(nodeDict['dimensions'])): for currDim in nodeDict['dimensions']: numberOfElements *= currDim - dataSourceText += ' NumberOfElements = ' + \ + mdsReaderText += ' NumberOfElements = ' + \ str(numberOfElements)+'\n' - dataSourceText += ' DataManagement = 1\n' if nodeDict['col_order']: - dataSourceText += ' UseColumnOrder = 1\n' + mdsReaderText += ' UseColumnOrder = 1\n' else: - dataSourceText += ' UseColumnOrder = 0\n' - dataSourceText += ' }\n' - dataSourceText += ' timebase = {\n' - dataSourceText += ' NumberOfElements = 1\n' - dataSourceText += ' Type = uint64\n' - dataSourceText += ' }\n' - - dataSourceText += ' }\n' - dataSourceText += ' }\n' - dataSources.append(dataSourceText) - + mdsReaderText += ' UseColumnOrder = 0\n' + mdsReaderText += ' DataManagement = 1\n' + mdsReaderText += ' }\n' + mdsReaderText += ' }\n' + gams.append(mdsReaderText) #Head and parameters dataSourceText = ' +'+dataSourceName+' = {\n' dataSourceText += ' Class = '+dataSourceClass+'\n' diff --git a/pydevices/RfxDevices/MARTE2_WRTDTIMER.py b/pydevices/RfxDevices/MARTE2_WRTDTIMER.py new file mode 100644 index 0000000000..5a8aa242e5 --- /dev/null +++ b/pydevices/RfxDevices/MARTE2_WRTDTIMER.py @@ -0,0 +1,55 @@ +# +# Copyright (c) 2017, Massachusetts Institute of Technology All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# Redistributions in binary form must reproduce the above copyright notice, this +# list of conditions and the following disclaimer in the documentation and/or +# other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +from MDSplus import Data + +MC = __import__('MARTE2_COMPONENT', globals()) + + +@MC.BUILDER('WRTDTimer', MC.MARTE2_COMPONENT.MODE_SYNCH_INPUT) +class MARTE2_WRTDTIMER(MC.MARTE2_COMPONENT): + outputs = [ + {'name': 'Counter', 'type': 'uint32', 'dimensions': 0, 'parameters': []}, + {'name': 'Time', 'type': 'int64', 'dimensions': 0, 'parameters': []}, + {'name': 'OutTrigger', 'type': 'uint8', 'dimensions': 0, 'parameters': []}, + {'name': 'AbsoluteTime', 'type': 'uint64', 'dimensions': -1, 'parameters': []}, + + ] + parameters = [ + {'name': 'ClockName', 'type': 'string', 'value': 'CLOCK_REALTIME'}, + {'name': 'CpuMask', 'type': 'int32', 'value': 127}, + {'name': 'UdpPort', 'type': 'uint32', 'value': 5044}, + {'name': 'EventName', 'type': 'string', 'value': "*"}, + {'name': 'MulticastGroup', 'type': 'string', 'value': "224.0.23.159"}, + {'name': 'LeapSeconds', 'type': 'int32', 'value': 0}, + {'name': 'Delay', 'type': 'float64', 'value': 0}, + {'name': 'Phase', 'type': 'float64', 'value': 0}, + {'name': 'Period', 'type': 'float64', 'value': 1E-1}, + ] + parts = [] + + def prepareMarteInfo(self): + self.timebase.putData(Data.compile( + ' (build_path("\\'+self.getFullPath()+'.parameters:par_7:value"))+(build_path("\\'+self.getFullPath()+'.parameters:par_8:value")): * : (build_path("\\'+self.getFullPath()+'.parameters:par_9:value"))'))