diff --git a/.gitignore b/.gitignore index f20007e..432baa4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +Trees # Prerequisites *.d diff --git a/Analysis/SdasImport2File.py b/Analysis/SdasImport2File.py index b20ee45..a5c49e7 100644 --- a/Analysis/SdasImport2File.py +++ b/Analysis/SdasImport2File.py @@ -15,6 +15,21 @@ import argparse from MdsImportSdas import StartSdas, LoadSdasData ISTTOK_RT_PERIOD = 0.0001 + +def build_import_table_magnetic(): + SDAS_NODEFMT = 'MARTE_NODE_IVO3.DataCollection.Channel_{}' + MAGNETIC_OFF = 166 + NUM_PROBES = 12 + + table = [] + for n in range(NUM_PROBES): + sdas_str = SDAS_NODEFMT.format(str(MAGNETIC_OFF + n).zfill(3)) + nd = {'sdas': sdas_str, + 'name': f'Mirnov coil no. {n+1}'} + table.append(nd) + return table + + def build_import_table_langmuir(): SDAS_NODEFMT = 'MARTE_NODE_IVO3.DataCollection.Channel_{}' LANGMUIR_OFF = 24 @@ -73,7 +88,7 @@ def get_arguments(): # type=int, help='Mds+ pulse Number ([1, ...])', # default=100) parser.add_argument('-f', '--file', type=str, - help='filename device to save', default='LangmuirSdas') + help='filename device to save', default='SdasData') parser.add_argument('-e', '--exportData', action='store_true', help='Export to MDSPlus') parser.add_argument('-m', '--mirnov', @@ -93,8 +108,8 @@ if (__name__ == "__main__"): args = get_arguments() pulseNo = args.pulse - nodeTable = build_import_table_langmuir() client = StartSdas() + nodeTable = build_import_table_langmuir() langmuirData = [] for nd in nodeTable: print(nd['sdas']) @@ -106,19 +121,41 @@ if (__name__ == "__main__"): trigger[args.trigger:] = 1 langmuirNp = np.array(langmuirData).T + + nodeTable = build_import_table_magnetic() + magneticData = [] + for nd in nodeTable: + print(nd['sdas']) + data, tzero_us, period = LoadSdasData(client, nd['sdas'], pulseNo) + magneticData.append(data) + + magneticNp = np.array(magneticData).T + data2file = np.insert(langmuirNp, 0, trigger, axis=1) + data2file = np.append(data2file, magneticNp, axis=1) + data2file = np.insert(data2file, 0, time, axis=1) if args.zeros > 0: nCol = data2file.shape[1] zerRows = np.zeros([args.zeros, nCol]) data2file = np.insert(data2file, 0, zerRows, axis=0) + fname = f"{args.file:s}_{pulseNo}" filename = f"{fname}.csv" # head = ('#Time (uint32)[1],Langmuir0 (float32)[1],Langmuir1 (float32)[1],' # 'Langmuir2 (float32)[1],Langmuir3 (float32)[1]') # formt = '%d,%.6f,%.6f,%.6f,%.6f' - formt = '%d,%d,{%.6f,%.6f,%.6f,%.6f}' - head = '#TimeSdas (uint32)[1],Trigger (uint32)[1],LangmuirSignals (float32)[4]' + # formt = '%d,%d,{%.6f,%.6f,%.6f,%.6f}' + # head = '#TimeSdas (uint32)[1],Trigger (uint32)[1],LangmuirSignals (float32)[4]' + + formt = ('%d,%d,{%.6f,%.6f,%.6f,%.6f},' + '{%.6g,%.6g,%.6g,%.6g,%.6g,%.6g,' + '%.6g,%.6g,%.6g,%.6g,%.6g,%.6g}') + + # head = '#TimeSdas (uint32)[1],Trigger (uint32)[1],LangmuirSignals (float32)[4]' + head = ('#TimeSdas (uint32)[1],Trigger (uint32)[1],' + 'LangmuirSignals (float32)[4],' + 'MagneticSignals (float32)[12]') np.savetxt(filename, data2file, fmt=formt, header=head, comments='') # , delimiter=',') diff --git a/Configurations/RTApp-Isttok-File.cfg b/Configurations/RTApp-Isttok-File.cfg index 5fd1c52..d8a1310 100644 --- a/Configurations/RTApp-Isttok-File.cfg +++ b/Configurations/RTApp-Isttok-File.cfg @@ -295,15 +295,19 @@ $MdsLoopApp = { Class = IOGAM InputSignals = { TimeSdas = { - DataSource = FileReader_DS + DataSource = FileReaderDS Type = uint32 } Trigger = { - DataSource = FileReader_DS + DataSource = FileReaderDS Type = uint32 } LangmuirSignals = { - DataSource = FileReader_DS + DataSource = FileReaderDS + Type = float32 + } + MagneticSignals = { + DataSource = FileReaderDS Type = float32 } } @@ -320,7 +324,32 @@ $MdsLoopApp = { DataSource = "DDB1" Type = float32 NumberOfElements = 4 +// NumberOfDimensions = 1 } + MagneticSignals = { + DataSource = "DDB1" + Type = float32 + NumberOfElements = 12 + NumberOfDimensions = 1 + } + } + } + +GAMConvert2Double = { + Class = "ConversionGAM" + InputSignals = { + MagneticSignals = { + DataSource = "DDB1" + Type = float32 + NumberOfElements = 12 + } + } + OutputSignals = { + MagneticSignalsD = { + DataSource = "DDB1" + Type = float64 + NumberOfElements = 12 + NumberOfDimensions = 1 + } } } +GAMLangSigs= { @@ -378,6 +407,119 @@ $MdsLoopApp = { } } } + +GAMMagSigs= { + Class = IOGAM + InputSignals = { + MagneticSignalsD = { + DataSource = "DDB1" + Type = float64 + NumberOfElements = 12 + } + } + OutputSignals = { + MirnovD0 = { + DataSource = "DDB1" + Type = float64 + } + MirnovD1 = { + DataSource = "DDB1" + Type = float64 + } + MirnovD2 = { + DataSource = "DDB1" + Type = float64 + } + MirnovD3 = { + DataSource = "DDB1" + Type = float64 + } + MirnovD4 = { + DataSource = "DDB1" + Type = float64 + } + MirnovD5 = { + DataSource = "DDB1" + Type = float64 + } + MirnovD6 = { + DataSource = "DDB1" + Type = float64 + } + MirnovD7 = { + DataSource = "DDB1" + Type = float64 + } + MirnovD8 = { + DataSource = "DDB1" + Type = float64 + } + MirnovD9 = { + DataSource = "DDB1" + Type = float64 + } + MirnovD10 = { + DataSource = "DDB1" + Type = float64 + } + MirnovD11 = { + DataSource = "DDB1" + Type = float64 + } + } + } + +GAMSSM = { + Class = SSMGAM + StateMatrix = {{1.0 0}{0 1.0}} //Compulsory + InputMatrix = {{0 0 0 0}{0 0 0 0}} //Compulsory + OutputMatrix = {{0 0}} //Compulsory + FeedthroughMatrix = {{1 1 1 1}} //Optional + ResetInEachState = 1//Compulsory. 1–> reset in each state, 0–> reset if the previous state is different from the next state + SampleFrequency = 0.0001 // Currently optional and not used. + InputSignals = { + MirnovD0 = { //input of the SS + DataSource = "DDB1" + Type = float64 //Only supported type. + NumberOfElements = 1 + NumberOfDimensions = 1 // or 0 + Samples = 1 + } + MirnovD1 = { + DataSource = "DDB1" + Type = float64 //Only supported type. + NumberOfElements = 1 + NumberOfDimensions = 1 + Samples = 1 + } + MirnovD2 = { + DataSource = "DDB1" + Type = float64 //Only supported type. + NumberOfElements = 1 + NumberOfDimensions = 1 + Samples = 1 + } + MirnovD3 = { + DataSource = "DDB1" + Type = float64 //Only supported type. + NumberOfElements = 1 + NumberOfDimensions = 1 + Samples = 1 + } + } + OutputSignals = { + OutputSignalSSM = { + DataSource = "DDB1" + Type = float64 + } + State0 = { + Type = float64 + DataSource = "DDB1" + } + State1 = { + Type = float64 + DataSource = "DDB1" + } + } + } +GAMFileWriter = { Class = IOGAM InputSignals = { @@ -401,28 +543,36 @@ $MdsLoopApp = { DataSource = "DDB1" Type = float32 } + OutputSignalSSM = { + DataSource = "DDB1" + Type = float64 + } } OutputSignals = { Time = { DataSource = FileWriter_DS Type = uint32 } - OutMdsW0 = { + OutLangW0 = { DataSource = FileWriter_DS Type = float32 } - OutMdsW1 = { + OutLangW1 = { DataSource = FileWriter_DS Type = float32 } - OutMdsW2 = { + OutLangW2 = { DataSource = FileWriter_DS Type = float32 } - OutMdsW3 = { + OutLangW3 = { DataSource = FileWriter_DS Type = float32 } + OutMag0 = { + DataSource = FileWriter_DS + Type = float64 + } } } @@ -452,9 +602,10 @@ $MdsLoopApp = { } } } - +FileReader_DS = { + +FileReaderDS = { Class = FileDataSource::FileReader - Filename = "../Analysis/LangmuirSdas_46241.csv" + // Filename = "../Analysis/LangmuirSdas_46241.csv" + Filename = "../Analysis/SdasData_46241.csv" FileFormat = "csv" CSVSeparator = "," Interpolate = "no" @@ -476,18 +627,22 @@ $MdsLoopApp = { Time = { Type = uint32 } - OutMdsW0 = { + OutLangW0 = { Type = float32 } - OutMdsW1 = { + OutLangW1 = { Type = float32 } - OutMdsW2 = { + OutLangW2 = { Type = float32 } - OutMdsW3 = { + OutLangW3 = { Type = float32 } + OutMag0 = { + Type = float64 + Format = "e" //Optional. Any format specifier supported by FormatDescriptor (without '') + } } } @@ -512,7 +667,7 @@ $MdsLoopApp = { +Thread1 = { Class = RealTimeThread CPUs = 0x1 - Functions = {GAMTimer GAMFileReader GAMLangSigs GAMElectricProbes GAMFileWriter } + Functions = {GAMTimer GAMFileReader GAMConvert2Double GAMMagSigs GAMSSM GAMLangSigs GAMElectricProbes GAMFileWriter } } } } diff --git a/Configurations/RTApp-Isttok-Mds.cfg b/Configurations/RTApp-Isttok-Mds.cfg index 35cb4cb..e520210 100644 --- a/Configurations/RTApp-Isttok-Mds.cfg +++ b/Configurations/RTApp-Isttok-Mds.cfg @@ -168,6 +168,22 @@ NextState = "PULSING" NextStateError = "IDLE" Timeout = 0 + +ChangeToRunMsg = { + Class = Message + Destination = MdsLoopApp + Mode = ExpectsReply + Function = PrepareNextState + +Parameters = { + Class = ConfigurationDatabase + param1 = Online + } + } + +CalcOffSetsMsg = { + Class = "Message" + Destination = "MdsLoopApp.Functions.GAMElectricProbes" + Function = "CalcOffSets" + Mode = "ExpectsReply" + } +StopCurrentStateExecutionMsg = { Class = Message Destination = MdsLoopApp @@ -302,9 +318,8 @@ $MdsLoopApp = { } } } - +GAMElectricProbes = { - Class = ElectricProbesGAM - Gain = 5 //Compulsory + +GAMLangSigs= { + Class = IOGAM InputSignals = { Langmuir0 = { DataSource = "DDB1" @@ -323,6 +338,50 @@ $MdsLoopApp = { Type = float32 } } + OutputSignals = { + LangmuirSigs = { + DataSource = "DDB1" + Type = float32 + NumberOfElements = 4 + } + } + } + +GAMElectricProbes = { + Class = ElectricProbesGAM + Gain = 5 //Compulsory + NumberOfSamplesAvg = 4 //Compulsory + ResetInEachState = 0//Compulsory. 1–> reset in each state, 0–> reset if the previous state is different from the next state + InputSignals = { + Time = { + DataSource = "DDB1" + Type = uint32 + } + LangmuirSigs = { + DataSource = "DDB1" + Type = float32 + NumberOfElements = 4 + } + } + /* + InputSignals = { + Langmuir0 = { + DataSource = "DDB1" + Type = float32 + } + Langmuir1 = { + DataSource = "DDB1" + Type = float32 + } + Langmuir2 = { + DataSource = "DDB1" + Type = float32 + } + Langmuir3 = { + DataSource = "DDB1" + Type = float32 + } + } + */ OutputSignals = { SignalEP_OutR = { DataSource = "DDB1" @@ -820,8 +879,8 @@ $MdsLoopApp = { NodeName = "\TOP.HARDWARE.ATCA1.IOC_1.CHANNEL_3.RAW" // node of the tree node Type = "float32" // Can be any of the node supported types NumberOfElements = 1 - DataManagement = 0 //could be 0, 1 or 2 - HoleManagement = 1 //could be 0 or 1 + DataManagement = 0 //could be 0, 0 –> MDSReader takes the data from the tree as it is (raw). 1 or 2 + HoleManagement = 1 //could be 0 or 1, 1-> fills the absence of data with the last value. } Time = { //Compulsory Type = "uint32" //can be any of the supported types @@ -849,8 +908,8 @@ $MdsLoopApp = { OutMdsW1 = { //As many as required. NodeName = "\TOP.OUT.OUT1" Period = 0.0001 - AutomaticSegmentation = 0 - MakeSegmentAfterNWrites = 100 + AutomaticSegmentation = 1 + // MakeSegmentAfterNWrites = 100 } OutMdsW2 = { NodeName = "\TOP.OUT.OUT2" @@ -887,7 +946,7 @@ $MdsLoopApp = { +Thread1 = { Class = RealTimeThread CPUs = 0x1 - Functions = {GAMTimer GAMWF1 GAMMDSReader GAMConvert2Double GAMElectricProbes GAMSSM GAMMDSWriter} + Functions = {GAMTimer GAMWF1 GAMMDSReader GAMConvert2Double GAMLangSigs GAMElectricProbes GAMSSM GAMMDSWriter} } } } diff --git a/Trees/ClearIsttokOutput.tcl b/Trees/ClearIsttokOutput.tcl new file mode 100644 index 0000000..621400e --- /dev/null +++ b/Trees/ClearIsttokOutput.tcl @@ -0,0 +1,3 @@ +set tree isttokoutput +create pulse 1 +exit