Bugfix in changing measurement channelConfig afterwards. Was not correctly fixed, as to store the enum index corresponding to the quantity
This commit is contained in:
parent
142a161283
commit
6758655eaa
@ -82,6 +82,12 @@ class Qty:
|
||||
return (self.name == other.name and
|
||||
self.unit_name == other.unit_name)
|
||||
|
||||
def toInt(self):
|
||||
"""
|
||||
Convert quantity to its specific enum integer value
|
||||
"""
|
||||
return self.cpp_enum.value
|
||||
|
||||
|
||||
|
||||
@unique
|
||||
|
@ -51,6 +51,7 @@ from scipy.io import wavfile
|
||||
import os, time, wave, logging
|
||||
from .lasp_common import SIQtys, Qty, getFreq
|
||||
from .lasp_cpp import Window, DaqChannel, LASP_VERSION_MAJOR
|
||||
from typing import List
|
||||
|
||||
|
||||
def getSampWidth(dtype):
|
||||
@ -311,14 +312,14 @@ class Measurement:
|
||||
return chcfg
|
||||
|
||||
@channelConfig.setter
|
||||
def channelConfig(self, chcfg):
|
||||
def channelConfig(self, chcfg: List[DaqChannel]):
|
||||
chname = []
|
||||
sens = []
|
||||
qtys = []
|
||||
for ch in chcfg:
|
||||
chname.append(ch.name)
|
||||
sens.append(ch.sensitivity)
|
||||
qtys.append(SIQtys.fromInt(ch.qty))
|
||||
qtys.append(SIQtys.fromCppEnum(ch.qty))
|
||||
|
||||
self.channelNames = chname
|
||||
self.sensitivity = sens
|
||||
@ -332,11 +333,14 @@ class Measurement:
|
||||
def qtys(self, newqtys):
|
||||
if not len(newqtys) == len(self._qtys):
|
||||
raise ValueError('Invalid number of quantities')
|
||||
qtys_json = [qty.to_json() for qty in newqtys]
|
||||
qtys_int = [qty.toInt() for qty in newqtys]
|
||||
# Use setAttribute here, but thos store the jsonified version as well,
|
||||
# which we have to overwrite again with the deserialized ones. This is
|
||||
# actually not a very nice way of coding.
|
||||
self.setAttribute('qtys', qtys_json)
|
||||
with self.file('r+') as f:
|
||||
# Update comment attribute in the file
|
||||
f.attrs['qtys_enum_idx'] = qtys_int
|
||||
|
||||
self._qtys = newqtys
|
||||
|
||||
@contextmanager
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* #define DEBUGTRACE_ENABLED */
|
||||
#include <armadillo>
|
||||
#define DEBUGTRACE_ENABLED
|
||||
#include "arma_npy.h"
|
||||
#include "debugtrace.hpp"
|
||||
#include "lasp_ppm.h"
|
||||
|
Loading…
Reference in New Issue
Block a user