Corrected WO setting by epics caput
Signed-off-by: Bernardo Carvalho <bernardo.carvalho@tecnico.ulisboa.pt>
This commit is contained in:
69
Analysis/calcDriftMds.py
Executable file
69
Analysis/calcDriftMds.py
Executable file
@@ -0,0 +1,69 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""
|
||||||
|
This script plots the MARTe2 ATCAIop samples stored in MDSplus
|
||||||
|
All of the plots may be panned/scaled by dragging with
|
||||||
|
the left/right mouse buttons. Right click on any plot to show a context menu.
|
||||||
|
"""
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
from MDSplus import Tree
|
||||||
|
import argparse
|
||||||
|
|
||||||
|
ADC_CHANNELS = 14 # channels stored in ISTTOK
|
||||||
|
DECIM_RATE = 200
|
||||||
|
|
||||||
|
def main(args):
|
||||||
|
mdsPulseNumber = args.shot
|
||||||
|
|
||||||
|
mdsTreeName = 'rtappisttok'
|
||||||
|
try:
|
||||||
|
tree = Tree(mdsTreeName, mdsPulseNumber)
|
||||||
|
except:
|
||||||
|
print(f'Failed opening {mdsTreeName} for pulse number {mdsPulseNumber:d}')
|
||||||
|
exit()
|
||||||
|
|
||||||
|
# add plt.addLegend() BEFORE you create the curves.
|
||||||
|
#mdsNode = tree.getNode("ATCAIOP1.ADC0RAW")
|
||||||
|
#dataAdc = mdsNode.getData().data()
|
||||||
|
#timeData = mdsNode.getDimensionAt(0).data()
|
||||||
|
start = args.crange[0] -1; stop = args.crange[1]
|
||||||
|
#for i in range(args.crange[0], args.crange[1]):
|
||||||
|
meanD = np.zeros(ADC_CHANNELS, dtype=int)
|
||||||
|
driftW = np.zeros(ADC_CHANNELS)
|
||||||
|
total_samples = 0
|
||||||
|
for i in range(ADC_CHANNELS):
|
||||||
|
mdsNode = tree.getNode(f"ATCAIOP1.ADC{i}RAW")
|
||||||
|
dataAdc = mdsNode.getData().data()
|
||||||
|
meanD[i] = np.mean(dataAdc[:,0]).astype(int)
|
||||||
|
mdsNode = tree.getNode(f"ATCAIOP1.ADC{i}INT")
|
||||||
|
dataAdcInt = mdsNode.getData().data()
|
||||||
|
total_samples = DECIM_RATE * len(dataAdcInt[:, 0])
|
||||||
|
driftW[i] = (dataAdcInt[-1, 0] - dataAdcInt[0, 0]) /total_samples
|
||||||
|
|
||||||
|
# if(args.averages):
|
||||||
|
print(f"EO: {ADC_CHANNELS} ", end='')
|
||||||
|
for i in range(ADC_CHANNELS):
|
||||||
|
print(f"{meanD[i]:d} ", end='')
|
||||||
|
print(" ")
|
||||||
|
print(f"WO: {ADC_CHANNELS} ", end='')
|
||||||
|
for i in range(ADC_CHANNELS):
|
||||||
|
print(f"{driftW[i]:0.3f} ", end='')
|
||||||
|
print(" ")
|
||||||
|
print(f"Samples {total_samples}, time {total_samples/2e3:.2f} ms")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
parser = argparse.ArgumentParser(description = 'Script to support the QA activities')
|
||||||
|
|
||||||
|
#parser.add_argument('-l','--list', nargs='+', help='<Required> Set flag', required=True)
|
||||||
|
#parser.add_argument('-l','--list', nargs='+')
|
||||||
|
parser.add_argument('-c', '--crange', nargs='+',type=int, help='Channel plots (1 12)',default=[1, 12])
|
||||||
|
parser.add_argument('-i', '--irange', nargs='+',type=int,default=[1, 12])
|
||||||
|
parser.add_argument('-s', '--shot', type=int, help='Mds+ pulse Number ([1, ...])', default=100)
|
||||||
|
#parser.add_argument('-e', '--averages', action='store_true', help='Calc averages')
|
||||||
|
#parser.add_argument('-w', '--drift', action='store_true', help='Calc drifts')
|
||||||
|
#, default='')
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
main(args)
|
||||||
|
# vim: set syntax=python ts=4 sw=4 sts=4 sr et
|
||||||
@@ -16,7 +16,7 @@ app = pg.mkQApp("Plotting MARTe2 AtcaIop Data")
|
|||||||
#mw.resize(800,800)
|
#mw.resize(800,800)
|
||||||
|
|
||||||
#MAX_SAMPLES = 50000
|
#MAX_SAMPLES = 50000
|
||||||
#ADC_CHANNELS = 4
|
ADC_CHANNELS = 14 # channels stored in ISTTOK
|
||||||
DECIM_RATE = 200
|
DECIM_RATE = 200
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description = 'Script to support the QA activities')
|
parser = argparse.ArgumentParser(description = 'Script to support the QA activities')
|
||||||
@@ -28,6 +28,9 @@ 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('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('-s', '--shot', type=int, help='Mds+ pulse Number ([1, ...])', default=100)
|
||||||
parser.add_argument('-m', '--maxpoints', type=int, help='Max points to plot', default=50000)
|
parser.add_argument('-m', '--maxpoints', type=int, help='Max points to plot', default=50000)
|
||||||
|
parser.add_argument('-e', '--averages', action='store_true', help='Calc averages')
|
||||||
|
#parser.add_argument('-w', '--drift', action='store_true', help='Calc drifts')
|
||||||
|
#, default='')
|
||||||
parser.add_argument('-z', '--zero', action='store_true',help='Zero integral Lines') #, default='')
|
parser.add_argument('-z', '--zero', action='store_true',help='Zero integral Lines') #, default='')
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
@@ -54,8 +57,32 @@ p1 = win.addPlot(title="ATCA-IOP ADC raw decimated")
|
|||||||
#dataAdc = mdsNode.getData().data()
|
#dataAdc = mdsNode.getData().data()
|
||||||
#timeData = mdsNode.getDimensionAt(0).data()
|
#timeData = mdsNode.getDimensionAt(0).data()
|
||||||
p1.addLegend()
|
p1.addLegend()
|
||||||
start = args.crange[0] -1; stop = args.crange[1] - 1
|
start = args.crange[0] -1; stop = args.crange[1]
|
||||||
#for i in range(args.crange[0], args.crange[1]):
|
#for i in range(args.crange[0], args.crange[1]):
|
||||||
|
meanD = np.zeros(ADC_CHANNELS, dtype=int)
|
||||||
|
driftW = np.zeros(ADC_CHANNELS)
|
||||||
|
total_samples = 0
|
||||||
|
for i in range(ADC_CHANNELS):
|
||||||
|
mdsNode = tree.getNode(f"ATCAIOP1.ADC{i}RAW")
|
||||||
|
dataAdc = mdsNode.getData().data()
|
||||||
|
meanD[i] = np.mean(dataAdc[:,0]).astype(int)
|
||||||
|
mdsNode = tree.getNode(f"ATCAIOP1.ADC{i}INT")
|
||||||
|
dataAdcInt = mdsNode.getData().data()
|
||||||
|
total_samples = DECIM_RATE * len(dataAdcInt[:, 0])
|
||||||
|
driftW[i] = (dataAdcInt[-1, 0] - dataAdcInt[0, 0]) /total_samples
|
||||||
|
|
||||||
|
if(args.averages):
|
||||||
|
print(f"EO: {ADC_CHANNELS} ", end='')
|
||||||
|
for i in range(ADC_CHANNELS):
|
||||||
|
print(f"{meanD[i]:d} ", end='')
|
||||||
|
print(" ")
|
||||||
|
print(f"WO: {ADC_CHANNELS} ", end='')
|
||||||
|
for i in range(ADC_CHANNELS):
|
||||||
|
print(f"{driftW[i]:0.3f} ", end='')
|
||||||
|
print(" ")
|
||||||
|
print(f"Samples {total_samples}, time {total_samples/2e3:.3f} ms")
|
||||||
|
|
||||||
|
|
||||||
for i in range(start, stop):
|
for i in range(start, stop):
|
||||||
mdsNode = tree.getNode(f"ATCAIOP1.ADC{i}RAW")
|
mdsNode = tree.getNode(f"ATCAIOP1.ADC{i}RAW")
|
||||||
dataAdc = mdsNode.getData().data()
|
dataAdc = mdsNode.getData().data()
|
||||||
@@ -69,8 +96,8 @@ win.nextRow()
|
|||||||
p4 = win.addPlot(title="Channel Integrals")
|
p4 = win.addPlot(title="Channel Integrals")
|
||||||
p4.addLegend()
|
p4.addLegend()
|
||||||
#for i in range(8,12):
|
#for i in range(8,12):
|
||||||
start = args.irange[0] -1; stop = args.irange[1] - 1
|
start = args.irange[0] -1; stop = args.irange[1]
|
||||||
print("WO: ", end='')
|
#print("WO: ", end='')
|
||||||
for i in range(start, stop):
|
for i in range(start, stop):
|
||||||
#mdsNode = tree.getNode(f"ATCAIOP1.ADC8INT")
|
#mdsNode = tree.getNode(f"ATCAIOP1.ADC8INT")
|
||||||
mdsNode = tree.getNode(f"ATCAIOP1.ADC{i}INT")
|
mdsNode = tree.getNode(f"ATCAIOP1.ADC{i}INT")
|
||||||
@@ -81,8 +108,8 @@ for i in range(start, stop):
|
|||||||
y = dataAdcInt[ :args.maxpoints, 0] / 2.0e6 # LSB * sec
|
y = dataAdcInt[ :args.maxpoints, 0] / 2.0e6 # LSB * sec
|
||||||
if(args.zero):
|
if(args.zero):
|
||||||
y = y - dataAdcInt[0, 0] / 2.0e6 # LSB * sec
|
y = y - dataAdcInt[0, 0] / 2.0e6 # LSB * sec
|
||||||
wo = (dataAdcInt[-1, 0] - dataAdcInt[0, 0]) /total_samples
|
#wo = (dataAdcInt[-1, 0] - dataAdcInt[0, 0]) /total_samples
|
||||||
print(f"{wo:0.4f} ", end='')
|
# print(f"{wo:0.4f} ", end='')
|
||||||
x = DECIM_RATE * np.arange(len(y)) / 2.0e6 # in sec
|
x = DECIM_RATE * np.arange(len(y)) / 2.0e6 # in sec
|
||||||
p4.plot(x,y, pen=pg.mkPen(i, width=2), name=f"Ch {i+1}")
|
p4.plot(x,y, pen=pg.mkPen(i, width=2), name=f"Ch {i+1}")
|
||||||
except:
|
except:
|
||||||
|
|||||||
@@ -433,10 +433,10 @@ bool AtcaIopADC::SetConfiguredDatabase(StructuredDataI& data) {
|
|||||||
ok = false;
|
ok = false;
|
||||||
REPORT_ERROR(ErrorManagement::FatalError, "Device Status Reg %d, 0x%x", rc, statusReg);
|
REPORT_ERROR(ErrorManagement::FatalError, "Device Status Reg %d, 0x%x", rc, statusReg);
|
||||||
}
|
}
|
||||||
rc = ioctl(boardFileDescriptor, ATCA_PCIE_IOPT_ACQ_ENABLE);
|
// rc = ioctl(boardFileDescriptor, ATCA_PCIE_IOPT_ACQ_ENABLE);
|
||||||
//rc = ioctl(boardFileDescriptor, ATCA_PCIE_IOPT_DMA_DISABLE);
|
//rc = ioctl(boardFileDescriptor, ATCA_PCIE_IOPT_DMA_DISABLE);
|
||||||
Sleep::Busy(0.001); // in Sec
|
//Sleep::Busy(0.001); // in Sec
|
||||||
rc = ioctl(boardFileDescriptor, ATCA_PCIE_IOPT_ACQ_DISABLE);
|
//rc = ioctl(boardFileDescriptor, ATCA_PCIE_IOPT_ACQ_DISABLE);
|
||||||
|
|
||||||
rc = ioctl(boardFileDescriptor, ATCA_PCIE_IOPT_IRQ_DISABLE);
|
rc = ioctl(boardFileDescriptor, ATCA_PCIE_IOPT_IRQ_DISABLE);
|
||||||
rc = ioctl(boardFileDescriptor, ATCA_PCIE_IOPT_STREAM_ENABLE);
|
rc = ioctl(boardFileDescriptor, ATCA_PCIE_IOPT_STREAM_ENABLE);
|
||||||
|
|||||||
@@ -37,7 +37,9 @@
|
|||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
#include "AdvancedErrorManagement.h"
|
#include "AdvancedErrorManagement.h"
|
||||||
#include "MemoryMapSynchronisedOutputBroker.h"
|
#include "MemoryMapSynchronisedOutputBroker.h"
|
||||||
|
|
||||||
#include "AtcaIopConfigEoWo.h"
|
#include "AtcaIopConfigEoWo.h"
|
||||||
|
#include "atca-v6-iop-ioctl.h"
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/* Static definitions */
|
/* Static definitions */
|
||||||
@@ -52,7 +54,7 @@ namespace MARTe {
|
|||||||
AtcaIopConfigEoWo::AtcaIopConfigEoWo() :
|
AtcaIopConfigEoWo::AtcaIopConfigEoWo() :
|
||||||
DataSourceI(),
|
DataSourceI(),
|
||||||
MessageI() {
|
MessageI() {
|
||||||
boardFileDescriptor = -1;
|
devFileDescriptor = -1;
|
||||||
//numberOfDACsEnabled = 0u;
|
//numberOfDACsEnabled = 0u;
|
||||||
//isMaster = 0u;
|
//isMaster = 0u;
|
||||||
deviceName = "";
|
deviceName = "";
|
||||||
@@ -76,10 +78,10 @@ namespace MARTe {
|
|||||||
|
|
||||||
/*lint -e{1551} the destructor must guarantee that the Timer SingleThreadService is stopped.*/
|
/*lint -e{1551} the destructor must guarantee that the Timer SingleThreadService is stopped.*/
|
||||||
AtcaIopConfigEoWo::~AtcaIopConfigEoWo() {
|
AtcaIopConfigEoWo::~AtcaIopConfigEoWo() {
|
||||||
if (boardFileDescriptor != -1) {
|
if (devFileDescriptor != -1) {
|
||||||
uint32 statusReg = 0;
|
uint32 statusReg = 0;
|
||||||
close(boardFileDescriptor);
|
close(devFileDescriptor);
|
||||||
REPORT_ERROR(ErrorManagement::Information, "Close device %d OK. Status Reg 0x%x,", boardFileDescriptor, statusReg);
|
REPORT_ERROR(ErrorManagement::Information, "Close device %d OK. Status Reg 0x%x,", devFileDescriptor, statusReg);
|
||||||
}
|
}
|
||||||
if (eoValues != NULL_PTR(int32 *)) {
|
if (eoValues != NULL_PTR(int32 *)) {
|
||||||
delete[] eoValues;
|
delete[] eoValues;
|
||||||
@@ -88,7 +90,7 @@ namespace MARTe {
|
|||||||
delete[] woValues;
|
delete[] woValues;
|
||||||
}
|
}
|
||||||
//if (channelsMemory != NULL_PTR(float32 *)) {
|
//if (channelsMemory != NULL_PTR(float32 *)) {
|
||||||
//delete[] channelsMemory;
|
//delete[] channelsMemory;
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,13 +116,13 @@ namespace MARTe {
|
|||||||
ok = false;
|
ok = false;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
bool ok = (signalIdx < (ATCA_IOP_MAX_DAC_CHANNELS));
|
bool ok = (signalIdx < (ATCA_IOP_MAX_DAC_CHANNELS));
|
||||||
if (ok) {
|
if (ok) {
|
||||||
if (channelsMemory != NULL_PTR(float32 *)) {
|
if (channelsMemory != NULL_PTR(float32 *)) {
|
||||||
signalAddress = &(channelsMemory[signalIdx]);
|
signalAddress = &(channelsMemory[signalIdx]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,141 +238,145 @@ namespace MARTe {
|
|||||||
//Get individual signal parameters
|
//Get individual signal parameters
|
||||||
//uint32 i = 0u;
|
//uint32 i = 0u;
|
||||||
/*
|
/*
|
||||||
|
if (ok) {
|
||||||
|
ok = data.MoveRelative("Signals");
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "Could not move to the Signals section");
|
||||||
|
}
|
||||||
|
//Do not allow to add signals in run-time
|
||||||
if (ok) {
|
if (ok) {
|
||||||
ok = data.MoveRelative("Signals");
|
ok = signalsDatabase.MoveRelative("Signals");
|
||||||
if (!ok) {
|
}
|
||||||
REPORT_ERROR(ErrorManagement::ParametersError, "Could not move to the Signals section");
|
if (ok) {
|
||||||
}
|
ok = signalsDatabase.Write("Locked", 1u);
|
||||||
//Do not allow to add signals in run-time
|
}
|
||||||
if (ok) {
|
if (ok) {
|
||||||
ok = signalsDatabase.MoveRelative("Signals");
|
ok = signalsDatabase.MoveToAncestor(1u);
|
||||||
}
|
}
|
||||||
if (ok) {
|
while ((i < ATCA_IOP_MAX_DAC_CHANNELS) && (ok)) {
|
||||||
ok = signalsDatabase.Write("Locked", 1u);
|
if (data.MoveRelative(data.GetChildName(i))) {
|
||||||
}
|
//uint32 channelId;
|
||||||
if (ok) {
|
float32 range;
|
||||||
ok = signalsDatabase.MoveToAncestor(1u);
|
ok = data.Read("OutputRange", range);
|
||||||
}
|
if (ok) {
|
||||||
while ((i < ATCA_IOP_MAX_DAC_CHANNELS) && (ok)) {
|
//if (data.Read("OutputRange", range)) {
|
||||||
if (data.MoveRelative(data.GetChildName(i))) {
|
ok = (range > 0.0) && (range <= ATCA_IOP_MAX_DAC_RANGE);
|
||||||
//uint32 channelId;
|
if (!ok) {
|
||||||
float32 range;
|
REPORT_ERROR(ErrorManagement::ParametersError, "Invalid OutputRange specified.");
|
||||||
ok = data.Read("OutputRange", range);
|
}
|
||||||
if (ok) {
|
if (ok) {
|
||||||
//if (data.Read("OutputRange", range)) {
|
outputRange[i] = range;
|
||||||
ok = (range > 0.0) && (range <= ATCA_IOP_MAX_DAC_RANGE);
|
REPORT_ERROR(ErrorManagement::Information, " Parameter DAC %d Output Range %f", i, range);
|
||||||
if (!ok) {
|
//dacEnabled[i] = true;
|
||||||
REPORT_ERROR(ErrorManagement::ParametersError, "Invalid OutputRange specified.");
|
numberOfDACsEnabled++;
|
||||||
}
|
}
|
||||||
if (ok) {
|
}
|
||||||
outputRange[i] = range;
|
else {
|
||||||
REPORT_ERROR(ErrorManagement::Information, " Parameter DAC %d Output Range %f", i, range);
|
REPORT_ERROR(ErrorManagement::ParametersError, "The OutputRange shall be specified.");
|
||||||
//dacEnabled[i] = true;
|
}
|
||||||
numberOfDACsEnabled++;
|
if (ok) {
|
||||||
}
|
ok = data.MoveToAncestor(1u);
|
||||||
}
|
}
|
||||||
else {
|
i++;
|
||||||
REPORT_ERROR(ErrorManagement::ParametersError, "The OutputRange shall be specified.");
|
}
|
||||||
}
|
else {
|
||||||
if (ok) {
|
break;
|
||||||
ok = data.MoveToAncestor(1u);
|
}
|
||||||
}
|
}
|
||||||
i++;
|
}
|
||||||
}
|
// REPORT_ERROR(ErrorManagement::Information, "numberOfDACsEnabled %d", numberOfDACsEnabled);
|
||||||
else {
|
//
|
||||||
break;
|
*/
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// REPORT_ERROR(ErrorManagement::Information, "numberOfDACsEnabled %d", numberOfDACsEnabled);
|
|
||||||
//
|
|
||||||
*/
|
|
||||||
|
|
||||||
return ok;
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AtcaIopConfigEoWo::SetConfiguredDatabase(StructuredDataI& data) {
|
||||||
|
uint32 i;
|
||||||
|
bool ok = DataSourceI::SetConfiguredDatabase(data);
|
||||||
|
|
||||||
|
if (ok) {
|
||||||
|
ok = triggerSet;
|
||||||
|
}
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "At least one Trigger signal shall be set.");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AtcaIopConfigEoWo::SetConfiguredDatabase(StructuredDataI& data) {
|
// Check the signal index
|
||||||
uint32 i;
|
uint32 nOfSignals = GetNumberOfSignals();
|
||||||
bool ok = DataSourceI::SetConfiguredDatabase(data);
|
if (ok) {
|
||||||
|
ok = (nOfSignals > 0u);
|
||||||
if (ok) {
|
|
||||||
ok = triggerSet;
|
|
||||||
}
|
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
REPORT_ERROR(ErrorManagement::ParametersError, "At least one Trigger signal shall be set.");
|
REPORT_ERROR(ErrorManagement::ParametersError, "At least one signal shall be defined");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Check the signal index
|
if (ok) {
|
||||||
uint32 nOfSignals = GetNumberOfSignals();
|
ok = (GetSignalType(0).type == SignedInteger);
|
||||||
if (ok) {
|
if (!ok) {
|
||||||
ok = (nOfSignals > 0u);
|
REPORT_ERROR(ErrorManagement::ParametersError, "EO signal shall be of type SignedInteger");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//In member function ‘virtual bool MARTe::AtcaIopConfigEoWo::SetConfiguredDatabase(MARTe::StructuredDataI&)’:
|
||||||
|
//AtcaIopConfigEoWo.cpp:311:49: error: no match for ‘operator==’ (operand types are ‘MARTe::BitRange<short unsigned int, 4, 2>’ and ‘const MARTe::TypeDescriptor’)
|
||||||
|
ok = (GetSignalType(1) == Float32Bit);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
REPORT_ERROR(ErrorManagement::ParametersError, "At least one signal shall be defined");
|
REPORT_ERROR(ErrorManagement::ParametersError, "WO signal shall be of type Float32Bit");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ok) {
|
}
|
||||||
ok = (GetSignalType(0).type == SignedInteger);
|
uint32 nOfFunctions = GetNumberOfFunctions();
|
||||||
if (!ok) {
|
uint32 functionIdx;
|
||||||
REPORT_ERROR(ErrorManagement::ParametersError, "EO signal shall be of type SignedInteger");
|
/*
|
||||||
}
|
//Check that the number of samples for all the signals is one
|
||||||
else {
|
for (functionIdx = 0u; (functionIdx < nOfFunctions) && (ok); functionIdx++) {
|
||||||
//In member function ‘virtual bool MARTe::AtcaIopConfigEoWo::SetConfiguredDatabase(MARTe::StructuredDataI&)’:
|
|
||||||
//AtcaIopConfigEoWo.cpp:311:49: error: no match for ‘operator==’ (operand types are ‘MARTe::BitRange<short unsigned int, 4, 2>’ and ‘const MARTe::TypeDescriptor’)
|
|
||||||
ok = (GetSignalType(1) == Float32Bit);
|
|
||||||
if (!ok) {
|
|
||||||
REPORT_ERROR(ErrorManagement::ParametersError, "WO signal shall be of type Float32Bit");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
uint32 nOfFunctions = GetNumberOfFunctions();
|
|
||||||
uint32 functionIdx;
|
|
||||||
/*
|
|
||||||
//Check that the number of samples for all the signals is one
|
|
||||||
for (functionIdx = 0u; (functionIdx < nOfFunctions) && (ok); functionIdx++) {
|
|
||||||
|
|
||||||
for (i = 0u; (i < nOfSignals) && (ok); i++) {
|
for (i = 0u; (i < nOfSignals) && (ok); i++) {
|
||||||
uint32 nSamples = 0u;
|
uint32 nSamples = 0u;
|
||||||
ok = GetFunctionSignalSamples(OutputSignals, functionIdx, i, nSamples);
|
ok = GetFunctionSignalSamples(OutputSignals, functionIdx, i, nSamples);
|
||||||
if (ok) {
|
if (ok) {
|
||||||
ok = (nSamples == 1u);
|
ok = (nSamples == 1u);
|
||||||
}
|
}
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
REPORT_ERROR(ErrorManagement::ParametersError, "The number of samples shall be exactly one");
|
REPORT_ERROR(ErrorManagement::ParametersError, "The number of samples shall be exactly one");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
StreamString fullDeviceName;
|
||||||
|
//Configure the board
|
||||||
|
if (ok) {
|
||||||
|
ok = fullDeviceName.Printf("%s_eo_%d", deviceName.Buffer(), boardId);
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
ok = fullDeviceName.Seek(0LLU);
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
devFileDescriptor = open(fullDeviceName.Buffer(), O_RDWR);
|
||||||
|
ok = (devFileDescriptor > -1);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR_PARAMETERS(ErrorManagement::ParametersError, "Could not open device %s", fullDeviceName);
|
||||||
}
|
}
|
||||||
*/
|
else
|
||||||
StreamString fullDeviceName;
|
REPORT_ERROR(ErrorManagement::Information, "Open device %s OK", fullDeviceName);
|
||||||
//Configure the board
|
}
|
||||||
if (ok) {
|
if (ok) {
|
||||||
ok = fullDeviceName.Printf("%s_eo_%d", deviceName.Buffer(), boardId);
|
//Allocate memory
|
||||||
}
|
eoValues = new int32[ATCA_IOP_MAX_ADC_CHANNELS];
|
||||||
if (ok) {
|
woValues = new float32[ATCA_IOP_MAX_ADC_CHANNELS];
|
||||||
ok = fullDeviceName.Seek(0LLU);
|
|
||||||
}
|
|
||||||
if (ok) {
|
|
||||||
boardFileDescriptor = open(fullDeviceName.Buffer(), O_RDWR);
|
|
||||||
ok = (boardFileDescriptor > -1);
|
|
||||||
if (!ok) {
|
|
||||||
REPORT_ERROR_PARAMETERS(ErrorManagement::ParametersError, "Could not open device %s", fullDeviceName);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
REPORT_ERROR(ErrorManagement::Information, "Open device %s OK", fullDeviceName);
|
|
||||||
}
|
|
||||||
if (ok) {
|
|
||||||
//Allocate memory
|
|
||||||
eoValues = new int32[ATCA_IOP_MAX_ADC_CHANNELS];
|
|
||||||
woValues = new float32[ATCA_IOP_MAX_ADC_CHANNELS];
|
|
||||||
}
|
|
||||||
|
|
||||||
return ok;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
bool AtcaIopConfigEoWo::Synchronise() {
|
|
||||||
uint32 i;
|
bool AtcaIopConfigEoWo::Synchronise() {
|
||||||
int32 w = 1;
|
uint32 i;
|
||||||
bool ok = true;
|
//int32 ewValues[2 * ATCA_IOP_MAX_ADC_CHANNELS];
|
||||||
|
struct atca_eo_config eo_conf;
|
||||||
|
struct atca_wo_config wo_conf;
|
||||||
|
int32 w = 1;
|
||||||
|
bool ok = true;
|
||||||
|
int rv;
|
||||||
#ifdef DEBUG_POLL
|
#ifdef DEBUG_POLL
|
||||||
if((synchCounter++)%4096 == 0) {
|
if((synchCounter++)%4096 == 0) {
|
||||||
//i = (synchCounter/4096) & 0xF;
|
//i = (synchCounter/4096) & 0xF;
|
||||||
@@ -379,48 +385,39 @@ namespace MARTe {
|
|||||||
#endif
|
#endif
|
||||||
if (eoWriteFlag) {
|
if (eoWriteFlag) {
|
||||||
eoWriteFlag = false;
|
eoWriteFlag = false;
|
||||||
REPORT_ERROR(ErrorManagement::Information, "Write eo0:%d wo0%0.3f", eoValues[0], woValues[0]);
|
for (i=0u; i < ATCA_IOP_MAX_ADC_CHANNELS ; i++) {
|
||||||
}
|
eo_conf.offset[i] = eoValues[i];
|
||||||
//write(boardFileDescriptor, &w, 4);
|
wo_conf.offset[i] = static_cast<int32>(woValues[i] * 65536);
|
||||||
/*
|
//ewValues[ATCA_IOP_MAX_ADC_CHANNELS + i] = static_cast<int32>(woValues[i] * 65536);
|
||||||
if (channelsMemory != NULL_PTR(float32 *)) {
|
|
||||||
|
|
||||||
// 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];
|
|
||||||
w = SetDacReg(i, value);
|
|
||||||
write(boardFileDescriptor, &w, 4);
|
|
||||||
// value = channelsMemory[1] / DAC_RANGE;
|
|
||||||
//value = channelsMemory[1] / DAC_RANGE * pow(2,17);
|
|
||||||
// w = SetDacReg(1, value);
|
|
||||||
//w = 0x000FFFFF & static_cast<uint32>(value);
|
|
||||||
// write(boardFileDescriptor, &w, 4);
|
|
||||||
//REPORT_ERROR(ErrorManagement::Information, " Writing DAC 0 0x%x", w);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
//rv = write(devFileDescriptor, &ewValues[0], 2 * ATCA_IOP_MAX_ADC_CHANNELS * sizeof(int32) );
|
||||||
w = dacValues[i];
|
rv = ioctl(devFileDescriptor, ATCA_PCIE_IOPS_EO_OFFSETS, &eo_conf);
|
||||||
}
|
if (rv ) {
|
||||||
*/
|
REPORT_ERROR(ErrorManagement::ParametersError, "Fail Write eo0:%d", eoValues[0]);
|
||||||
return ok;
|
ok = false;
|
||||||
|
}
|
||||||
|
rv = ioctl(devFileDescriptor, ATCA_PCIE_IOPS_WO_OFFSETS, &wo_conf);
|
||||||
|
if (rv ) {
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "Fail Write wo0:%6.3f", woValues[0]);
|
||||||
|
ok = false;
|
||||||
|
}
|
||||||
|
rv = ioctl(devFileDescriptor, ATCA_PCIE_IOPT_RST_INTEG);
|
||||||
|
if (rv ) {
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "Fail reset Integrators");
|
||||||
|
ok = false;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
if (rv != 2 * ATCA_IOP_MAX_ADC_CHANNELS * sizeof(int32) ) {
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "Fail Write eo0:%d", eoValues[0]);
|
||||||
|
ok = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
REPORT_ERROR(ErrorManagement::Information, "Write eo0:%d wo0%0.3f", eoValues[0], woValues[0]);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
int32 AtcaIopConfigEoWo::SetDacReg(uint32 channel, float32 val) const {
|
CLASS_REGISTER(AtcaIopConfigEoWo, "1.0")
|
||||||
if (val > 1.0)
|
|
||||||
val = 1.0;
|
|
||||||
if (val < -1.0)
|
|
||||||
val = -1.0;
|
|
||||||
int32 dacReg = static_cast<int32>(val * pow(2,17));
|
|
||||||
if (dacReg > 0x1FFFF) // 131071
|
|
||||||
dacReg = 0x1FFFF;
|
|
||||||
if (dacReg < -131072) // -0x20000
|
|
||||||
dacReg = -131072;
|
|
||||||
dacReg &= 0x0003FFFF; // keep 18 lsb
|
|
||||||
dacReg |= (0xF & channel) << 28;
|
|
||||||
return dacReg;
|
|
||||||
}
|
|
||||||
|
|
||||||
CLASS_REGISTER(AtcaIopConfigEoWo, "1.0")
|
|
||||||
}
|
}
|
||||||
// vim: syntax=cpp ts=4 sw=4 sts=4 sr et
|
// vim: syntax=cpp ts=4 sw=4 sts=4 sr et
|
||||||
|
|||||||
@@ -195,7 +195,7 @@ namespace MARTe {
|
|||||||
/**
|
/**
|
||||||
* The board file descriptor
|
* The board file descriptor
|
||||||
*/
|
*/
|
||||||
int32 boardFileDescriptor;
|
int32 devFileDescriptor;
|
||||||
|
|
||||||
uint32 synchCounter;
|
uint32 synchCounter;
|
||||||
/**
|
/**
|
||||||
@@ -235,7 +235,7 @@ namespace MARTe {
|
|||||||
*/
|
*/
|
||||||
bool triggerSet;
|
bool triggerSet;
|
||||||
|
|
||||||
int32 SetDacReg(uint32 channel, float32 val) const;
|
//int32 SetDacReg(uint32 channel, float32 val) const;
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,7 +86,9 @@ struct atca_wo_config {
|
|||||||
|
|
||||||
#define ATCA_PCIE_IOPG_DACS_REG _IOR(ATCA_PCIE_IOP_MAGIC, 29, u_int32_t)
|
#define ATCA_PCIE_IOPG_DACS_REG _IOR(ATCA_PCIE_IOP_MAGIC, 29, u_int32_t)
|
||||||
|
|
||||||
#define ATCA_PCIE_IOP_MAXNR 29
|
#define ATCA_PCIE_IOPT_RST_INTEG _IO(ATCA_PCIE_IOP_MAGIC, 30)
|
||||||
|
|
||||||
|
#define ATCA_PCIE_IOP_MAXNR 30
|
||||||
|
|
||||||
#endif /* _ATCA_IOP_IOPTL_H_ */
|
#endif /* _ATCA_IOP_IOPTL_H_ */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user