diff --git a/Analysis/pyqtPlotMds.py b/Analysis/pyqtPlotMds.py index 9ee5633..2a9344e 100755 --- a/Analysis/pyqtPlotMds.py +++ b/Analysis/pyqtPlotMds.py @@ -15,8 +15,8 @@ app = pg.mkQApp("Plotting MARTe2 AtcaIop Data") #mw = QtWidgets.QMainWindow() #mw.resize(800,800) -MAX_SAMPLES = 50000 -ADC_CHANNELS = 4 +#MAX_SAMPLES = 50000 +#ADC_CHANNELS = 4 DECIM_RATE = 200 parser = argparse.ArgumentParser(description = 'Script to support the QA activities') @@ -27,7 +27,7 @@ parser.add_argument('-c', '--crange', nargs='+',type=int, help='Channel plots (1 parser.add_argument('-i', '--irange', nargs='+',type=int,default=[1, 12]) #parser.add_argument('pulse','-', nargs='+', help=' Set flag', required=True) parser.add_argument('-s', '--shot', type=int, help='Mds+ pulse Number ([1, ...])', default=100) -parser.add_argument('-m', '--maxsamples', type=int, help='Max samples to plot', default=50000) +parser.add_argument('-m', '--maxpoints', type=int, help='Max points to plot', default=50000) parser.add_argument('-z', '--zero', action='store_true',help='Zero integral Lines') #, default='') args = parser.parse_args() @@ -60,8 +60,7 @@ for i in range(start, stop): mdsNode = tree.getNode(f"ATCAIOP1.ADC{i}RAW") dataAdc = mdsNode.getData().data() timeData = mdsNode.getDimensionAt(0).data() - #y = dataAdc[ :args.maxsamples, 0] - y = dataAdc[ :MAX_SAMPLES, 0] + y = dataAdc[ :args.maxpoints, 0] x = DECIM_RATE * np.arange(len(y)) / 2.0e6 p1.plot(x,y, pen=pg.mkPen(i, width=2), name=f"Ch {i+1}") #p1.setLabel('bottom', "Y Axis", units='s') @@ -79,7 +78,7 @@ for i in range(start, stop): dataAdcInt = mdsNode.getData().data() timeData = mdsNode.getDimensionAt(0).data() total_samples = DECIM_RATE * len(dataAdcInt[:, 0]) - y = dataAdcInt[ :args.maxsamples, 0] / 2.0e6 # LSB * sec + y = dataAdcInt[ :args.maxpoints, 0] / 2.0e6 # LSB * sec if(args.zero): y = y - dataAdcInt[0, 0] / 2.0e6 # LSB * sec wo = (dataAdcInt[-1, 0] - dataAdcInt[0, 0]) /total_samples @@ -96,5 +95,10 @@ p4.setLabel('bottom', "Time", units='s') #updatePlot() if __name__ == '__main__': - pg.exec() + import sys + if sys.flags.interactive != 1 or not hasattr(QtCore, 'PYQT_VERSION'): + pg.QtGui.QApplication.exec_() + + #iprint("xwc") + #pg.exec() # vim: syntax=python ts=4 sw=4 sts=4 sr et diff --git a/Configurations/README.md b/Configurations/README.md new file mode 100644 index 0000000..21198ec --- /dev/null +++ b/Configurations/README.md @@ -0,0 +1,2 @@ +# Replace lines with sed +`sed -i "s/BoardId =.*/BoardId = 9/g" RTApp-AtcaIop-ppr9.cfg` diff --git a/Configurations/RTApp-AtcaIop.cfg b/Configurations/RTApp-AtcaIop.cfg index 1d4d749..af1ba1e 100644 --- a/Configurations/RTApp-AtcaIop.cfg +++ b/Configurations/RTApp-AtcaIop.cfg @@ -563,6 +563,36 @@ $IsttokApp = { } } } + +AtcaGAMEoWoOutput = { + Class = "IOGAM" + InputSignals = { + EoArr = { + DataSource = "DDB1" + NumberOfDimensions = "1" + NumberOfElements = "16" + Type = "int32" + } + WoArr = { + DataSource = "DDB1" + NumberOfDimensions = "1" + NumberOfElements = "16" + Type = "float32" + } + } + OutputSignals = { + EO = { + DataSource = AtcaIopConfigEoWo_2 + Type = int32 + NumberOfElements = "16" + Trigger = 1 + } + WO = { + DataSource = AtcaIopConfigEoWo_2 + NumberOfElements = "16" + Type = float32 + } + } + } +GAMConvert2Volt = { Class = "ConversionGAM" InputSignals = { @@ -1129,10 +1159,25 @@ $IsttokApp = { +Timings = { Class = "TimingDataSource" } + +AtcaIopConfigEoWo_2 = { + Class = AtcaIop::AtcaIopConfigEoWo + //CPUMask = "0xC" + DeviceName = "/dev/atca_v6" + BoardId = 2 //Mandatory + Signals = { + EO = { + Type = int32 //Mandatory. Only type that is supported. + } + WO = { + Type = float32 //Mandatory. Only type that is supported. + } + } + } +AtcaIop_0_DAC = { Class = "AtcaIop::AtcaIopDAC" //CPUMask = "0xC" - DeviceName = "/dev/atca_v6_dac_9" + DeviceName = "/dev/atca_v6" + BoardId = 2 //Mandatory //NumberOfChannels = 2 Signals = { DAC0 = { @@ -1149,12 +1194,13 @@ $IsttokApp = { +AtcaIop_0_ADC = { Class = "AtcaIop::AtcaIopADC" CPUMask = "0xC" - DeviceName = "/dev/atca_v6_9" - DeviceDmaName = "/dev/atca_v6_dmart_9" + DeviceName = "/dev/atca_v6" + BoardId = 2 //Mandatory + DeviceDmaName = "/dev/atca_v6_dmart_2" NumberOfChannels = "12" IsMaster = "1" SleepNature = "Busy" - SleepPercentage = "0" + SleepPercentage = "20" ADCFrequency = "2000000" RTDecimation = "200" ChopperPeriod = "2000" @@ -1227,6 +1273,66 @@ $IsttokApp = { } ADC6Integral = { Type = "int64" + +AtcaGAMEoWoOutput = { + Class = "IOGAM" + InputSignals = { + EoArr = { + DataSource = "DDB1" + NumberOfDimensions = "1" + NumberOfElements = "16" + Type = "int32" + +AtcaGAMEoWoOutput = { + Class = "IOGAM" + InputSignals = { + EoArr = { + DataSource = "DDB1" + NumberOfDimensions = "1" + NumberOfElements = "16" + Type = "int32" + } + WoArr = { + DataSource = "DDB1" + NumberOfDimensions = "1" + NumberOfElements = "16" + Type = "float32" + } + } + OutputSignals = { + EO = { + DataSource = AtcaIopConfigEoWo_2 + Type = int32 + NumberOfElements = "16" + Trigger = 1 + } + WO = { + DataSource = AtcaIopConfigEoWo_2 + NumberOfElements = "16" + Type = float32 + } + } + } + } + WoArr = { + DataSource = "DDB1" + NumberOfDimensions = "1" + NumberOfElements = "16" + Type = "float32" + } + } + OutputSignals = { + EO = { + DataSource = AtcaIopConfigEoWo_2 + Type = int32 + NumberOfElements = "16" + Trigger = 1 + } + WO = { + DataSource = AtcaIopConfigEoWo_2 + NumberOfElements = "16" + Type = float32 + } + } + } } ADC7Integral = { Type = "int64" @@ -1547,7 +1653,8 @@ $IsttokApp = { +Thread1 = { Class = "RealTimeThread" CPUs = "0x4" - Functions = {"AtcaGAMInput" "DacConstants" "AtcaGAMOutput" "GAMConvert2Volt" "GAMConvert2Float" "GAMHistogramCycleTimes" "GAMCAOutput"} + //Functions = {"AtcaGAMInput" "DacConstants" "AtcaGAMOutput" "GAMConvert2Volt" "GAMConvert2Float" "GAMHistogramCycleTimes" "GAMCAOutput"} + Functions = {"AtcaGAMInput" "DacConstants" "AtcaGAMOutput" "AtcaGAMEoWoOutput" "GAMConvert2Volt" "GAMConvert2Float" "GAMHistogramCycleTimes" "GAMCAOutput" "GAMCAInput"} } } diff --git a/DataSources/AtcaIop/AtcaIopADC.cpp b/DataSources/AtcaIop/AtcaIopADC.cpp index 348891f..da2d4a3 100644 --- a/DataSources/AtcaIop/AtcaIopADC.cpp +++ b/DataSources/AtcaIop/AtcaIopADC.cpp @@ -40,6 +40,7 @@ #include "AtcaIopADC.h" #include "atca-v6-iop-ioctl.h" +#define DEBUG_POLL 1 /*---------------------------------------------------------------------------*/ /* Static definitions */ /*---------------------------------------------------------------------------*/ @@ -77,9 +78,9 @@ struct atca_wo_config { /*---------------------------------------------------------------------------*/ AtcaIopADC::AtcaIopADC() : DataSourceI(), MessageI(), EmbeddedServiceMethodBinderI(), executor(*this) { - //boardId = 2u; deviceName = ""; - deviceDmaName = ""; + boardId = 2u; + //deviceDmaName = ""; boardFileDescriptor = -1; boardDmaDescriptor = -1; mappedDmaBase = NULL; @@ -93,6 +94,8 @@ AtcaIopADC::AtcaIopADC() : counterAndTimer[1] = 0u; sleepNature = Busy; sleepPercentage = 0u; + execCounter = 0u; + pollTimout = 0u; adcPeriod = 0.; uint32 k; for (k=0u; k(periodUsec); float64 sleepTimeT = (static_cast(HighResolutionTimer::Frequency()) / cycleFrequency); sleepTimeTicks = static_cast(sleepTimeT); +/* + * [Information - AtcaIopADC.cpp:548]: The timer will be set using a cycle frequency of 10000.000000 Hz + * [Information - AtcaIopADC.cpp:554]: The timer will be set using a sleepTimeTicks of 100000 (ns) + */ REPORT_ERROR(ErrorManagement::Information, "The timer will be set using a sleepTimeTicks of %d (ns)", sleepTimeTicks); } @@ -613,6 +630,9 @@ bool AtcaIopADC::PrepareNextState(const char8* const currentStateName, const cha ok = executor.Start(); REPORT_ERROR(ErrorManagement::Information, "Executor Start"); } + if (executor.GetStatus() == EmbeddedThreadI::RunningState) { + REPORT_ERROR(ErrorManagement::Information, " ADC currentStateName %s, nextStateName %s", currentStateName, nextStateName); + } counterAndTimer[0] = 0u; //counterAndTimer[1] = 0u; return ok; @@ -638,19 +658,32 @@ ErrorManagement::ErrorType AtcaIopADC::Execute(ExecutionInfo& info) { uint64 deltaTicks = sleepTimeTicks - sleepTicksCorrection; //volatile int32 currentDMA = 0u; oldestBufferIdx = GetOldestBufferIdx(); + float32 totalSleepTime = static_cast(static_cast(deltaTicks) * HighResolutionTimer::Period()); +#ifdef DEBUG_POLL + if((execCounter++)%4096 == 0) { + REPORT_ERROR(ErrorManagement::Information, "Executor sleepTime: %f pollTimout: %d", totalSleepTime, pollTimout); + } +#endif if (sleepNature == Busy) { - if (sleepPercentage == 0u) { + if (sleepPercentage > 0u) { + //float32 sleepTime = totalSleepTime * 0.5; + float32 sleepTime = totalSleepTime * (static_cast(sleepPercentage) / 100.F); + Sleep::NoMore(sleepTime); //currentDMA = - PollDma(startTicks + deltaTicks + 100000u); // TODO check max wait + //if(PollDma(startTicks + deltaTicks + 100000u) < 0) //while ((HighResolutionTimer::Counter() - startTicks) < deltaTicks) { //} } + if(PollDma(startTicks + deltaTicks + sleepTimeTicks + 10000u) < 0) + pollTimout++; // TODO check max wait + /* else { float32 totalSleepTime = static_cast(static_cast(deltaTicks) * HighResolutionTimer::Period()); uint32 busyPercentage = (100u - sleepPercentage); float32 busyTime = totalSleepTime * (static_cast(busyPercentage) / 100.F); Sleep::SemiBusy(totalSleepTime, busyTime); } + */ } else { float32 sleepTime = static_cast(static_cast(deltaTicks) * HighResolutionTimer::Period()); @@ -691,6 +724,9 @@ uint32 AtcaIopADC::GetStackSize() const { uint32 AtcaIopADC::GetSleepPercentage() const { return sleepPercentage; } +/* + * waitLimitTicks in ns + * */ int32 AtcaIopADC::PollDma(uint64 waitLimitTicks) const { uint32 buffIdx = oldestBufferIdx; diff --git a/DataSources/AtcaIop/AtcaIopADC.h b/DataSources/AtcaIop/AtcaIopADC.h index 790298d..6f348f3 100644 --- a/DataSources/AtcaIop/AtcaIopADC.h +++ b/DataSources/AtcaIop/AtcaIopADC.h @@ -248,7 +248,7 @@ namespace MARTe { /** * The board identifier */ - //uint32 boardId; + uint32 boardId; /** * The numberOfChannels */ @@ -264,7 +264,7 @@ namespace MARTe { /** * The board device name */ - StreamString deviceDmaName; + //StreamString deviceDmaName; /** * The board file descriptor */ @@ -294,6 +294,12 @@ namespace MARTe { */ AtcaIopADCSleepNature sleepNature; + /** + * Debugging + */ + uint32 execCounter; + uint32 pollTimout; + /** * Current counter and timer */ diff --git a/DataSources/AtcaIop/AtcaIopConfigEoWo.cpp b/DataSources/AtcaIop/AtcaIopConfigEoWo.cpp index ad8b940..3976ae4 100644 --- a/DataSources/AtcaIop/AtcaIopConfigEoWo.cpp +++ b/DataSources/AtcaIop/AtcaIopConfigEoWo.cpp @@ -77,7 +77,6 @@ namespace MARTe { AtcaIopConfigEoWo::~AtcaIopConfigEoWo() { if (boardFileDescriptor != -1) { uint32 statusReg = 0; - //REPORT_ERROR(ErrorManagement::Information, " Close Device Status Reg %d, 0x%x", rc, statusReg); close(boardFileDescriptor); REPORT_ERROR(ErrorManagement::Information, "Close device %d OK. Status Reg 0x%x,", boardFileDescriptor, statusReg); } @@ -206,6 +205,9 @@ namespace MARTe { /*lint -e{715} [MISRA C++ Rule 0-1-11], [MISRA C++ Rule 0-1-12]. Justification: the counter and the timer are always reset irrespectively of the states being changed.*/ bool AtcaIopConfigEoWo::PrepareNextState(const char8* const currentStateName, const char8* const nextStateName) { REPORT_ERROR(ErrorManagement::Information, " EoWo currentStateName %s, nextStateName %s", currentStateName, nextStateName); + //if (currentStateName == "Idle") { + // REPORT_ERROR(ErrorManagement::Information, "OffState"); + //} return true; } @@ -351,7 +353,6 @@ namespace MARTe { } if (ok) { //Allocate memory - //channelsMemory = new float32[ATCA_IOP_MAX_DAC_CHANNELS]; eoValues = new int32[ATCA_IOP_MAX_ADC_CHANNELS]; woValues = new float32[ATCA_IOP_MAX_ADC_CHANNELS]; } @@ -362,11 +363,15 @@ namespace MARTe { bool AtcaIopConfigEoWo::Synchronise() { uint32 i; - int32 w; + int32 w = 1; bool ok = true; +#ifdef DEBUG_POLL if((synchCounter++)%4096 == 0) { - REPORT_ERROR(ErrorManagement::Information, " Synchronise"); + //i = (synchCounter/4096) & 0xF; + REPORT_ERROR(ErrorManagement::Information, "Synchronise eo0:%d wo0%0.3f", eoValues[0], woValues[0]); } +#endif + //write(boardFileDescriptor, &w, 4); /* if (channelsMemory != NULL_PTR(float32 *)) { diff --git a/DataSources/AtcaIop/AtcaIopDAC.cpp b/DataSources/AtcaIop/AtcaIopDAC.cpp index 82bf70b..d7fc792 100644 --- a/DataSources/AtcaIop/AtcaIopDAC.cpp +++ b/DataSources/AtcaIop/AtcaIopDAC.cpp @@ -57,6 +57,7 @@ namespace MARTe { numberOfDACsEnabled = 0u; //isMaster = 0u; deviceName = ""; + boardId = 2u; triggerSet = false; uint32 n; for (n = 0u; n < ATCA_IOP_MAX_DAC_CHANNELS; n++) { @@ -198,6 +199,12 @@ namespace MARTe { } } + if (ok) { + ok = data.Read("BoardId", boardId); + if (!ok) { + REPORT_ERROR(ErrorManagement::ParametersError, "The BoardId shall be specified"); + } + } //if (!data.Read("IsMaster", isMaster)) { // REPORT_ERROR(ErrorManagement::Warning, "IsMaster not specified. Using default: %d", isMaster); //} @@ -232,7 +239,7 @@ namespace MARTe { } if (ok) { outputRange[i] = range; - REPORT_ERROR(ErrorManagement::Information, " Parameter DAC %d Output Range %f", i, range); + REPORT_ERROR(ErrorManagement::Information, " Parameter DAC %d Output Range %f", i, range); //dacEnabled[i] = true; numberOfDACsEnabled++; } @@ -303,7 +310,8 @@ namespace MARTe { StreamString fullDeviceName; //Configure the board if (ok) { - ok = fullDeviceName.Printf("%s", deviceName.Buffer()); + ok = fullDeviceName.Printf("%s_dac_%d", deviceName.Buffer(), boardId); + //ok = fullDeviceName.Printf("%s", deviceName.Buffer()); } if (ok) { ok = fullDeviceName.Seek(0LLU); @@ -332,7 +340,7 @@ namespace MARTe { bool ok = true; if (channelsMemory != NULL_PTR(float32 *)) { -// value = channelsMemory[0] / DAC_RANGE; + // value = channelsMemory[0] / DAC_RANGE; for (i = 0u; (i < 2u) && (ok); i++) { //for (i = 0u; (i < numberOfDACsEnabled ) && (ok); i++) { float32 value = channelsMemory[i] / outputRange[i]; @@ -345,12 +353,12 @@ namespace MARTe { // write(boardFileDescriptor, &w, 4); //REPORT_ERROR(ErrorManagement::Information, " Writing DAC 0 0x%x", w); } - } - /* + } + /* - w = dacValues[i]; - } - */ + w = dacValues[i]; + } + */ return ok; } diff --git a/DataSources/AtcaIop/AtcaIopDAC.h b/DataSources/AtcaIop/AtcaIopDAC.h index 79b69c6..8cfe34e 100644 --- a/DataSources/AtcaIop/AtcaIopDAC.h +++ b/DataSources/AtcaIop/AtcaIopDAC.h @@ -182,6 +182,10 @@ namespace MARTe { * The board device name */ StreamString deviceName; + /** + * The board identifier + */ + uint32 boardId; /** * The board file descriptor */