EoWo Datasource running

Signed-off-by: Bernardo Carvalho <bernardo.carvalho@tecnico.ulisboa.pt>
This commit is contained in:
2024-04-18 18:22:44 +01:00
parent 06242bd5c9
commit 9b01d22ea4
8 changed files with 204 additions and 32 deletions

View File

@@ -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='<Required> 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

2
Configurations/README.md Normal file
View File

@@ -0,0 +1,2 @@
# Replace lines with sed
`sed -i "s/BoardId =.*/BoardId = 9/g" RTApp-AtcaIop-ppr9.cfg`

View File

@@ -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"}
}
}

View File

@@ -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<ATCA_IOP_N_ADCs; k++) {
@@ -153,12 +156,20 @@ bool AtcaIopADC::Initialise(StructuredDataI& data) {
REPORT_ERROR(ErrorManagement::ParametersError, "The DeviceName shall be specified");
}
}
if (ok) {
ok = data.Read("BoardId", boardId);
if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "The BoardId shall be specified");
}
}
/*
if (ok) {
ok = data.Read("DeviceDmaName", deviceDmaName);
if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "The DeviceDmaName shall be specified");
}
}
*/
if (ok) {
ok = data.Read("NumberOfChannels", numberOfChannels);
if (!ok) {
@@ -343,7 +354,8 @@ bool AtcaIopADC::SetConfiguredDatabase(StructuredDataI& data) {
StreamString fullDeviceName;
//Configure the board
if (ok) {
ok = fullDeviceName.Printf("%s", deviceName.Buffer());
ok = fullDeviceName.Printf("%s_%d", deviceName.Buffer(), boardId);
//ok = fullDeviceName.Printf("%s", deviceName.Buffer());
}
if (ok) {
ok = fullDeviceName.Seek(0LLU);
@@ -359,7 +371,8 @@ bool AtcaIopADC::SetConfiguredDatabase(StructuredDataI& data) {
}
ok = fullDeviceName.Seek(0LLU);
if (ok) {
ok = fullDeviceName.Printf("%s", deviceDmaName.Buffer());
ok = fullDeviceName.Printf("%s_dmart_%d", deviceName.Buffer(), boardId);
//ok = fullDeviceName.Printf("%s", deviceName.Buffer());
}
if (ok) {
ok = fullDeviceName.Seek(0LLU);
@@ -538,6 +551,10 @@ bool AtcaIopADC::SetConfiguredDatabase(StructuredDataI& data) {
timerPeriodUsecTime = static_cast<uint32>(periodUsec);
float64 sleepTimeT = (static_cast<float64>(HighResolutionTimer::Frequency()) / cycleFrequency);
sleepTimeTicks = static_cast<uint64>(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<float32>(static_cast<float64>(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<float32>(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<float32>(static_cast<float64>(deltaTicks) * HighResolutionTimer::Period());
uint32 busyPercentage = (100u - sleepPercentage);
float32 busyTime = totalSleepTime * (static_cast<float32>(busyPercentage) / 100.F);
Sleep::SemiBusy(totalSleepTime, busyTime);
}
*/
}
else {
float32 sleepTime = static_cast<float32>(static_cast<float64>(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;

View File

@@ -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
*/

View File

@@ -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 *)) {

View File

@@ -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;
}

View File

@@ -182,6 +182,10 @@ namespace MARTe {
* The board device name
*/
StreamString deviceName;
/**
* The board identifier
*/
uint32 boardId;
/**
* The board file descriptor
*/