Compare commits

...

7 Commits

Author SHA1 Message Date
Roy c96f76f438 [update] read RAM data bug 2022-06-10 17:22:10 +08:00
Roy f0f1c9fc49 [update] update eis json 2022-06-10 17:20:58 +08:00
Roy 499964b287 [update] fix TIME_DURATION in eis devlib 2022-05-23 17:42:12 +08:00
Roy 16f12d40bf [update] improve cp and cc mode - speed and resistance value 2022-05-20 12:11:56 +08:00
peterlu14 63c1ba8efb [update] update decorder mode in I4V4Z4T4 2022-05-18 16:16:17 +08:00
Roy 4a28348db4 [update] fix cp mode instruction and decoder 2022-05-18 11:06:23 +08:00
peterlu14 64dfe87d05 [update] remove decorder rebuild problem & add new parameter to control time duration 2022-05-18 10:19:08 +08:00
8 changed files with 146 additions and 60 deletions
+2
View File
@@ -1,5 +1,7 @@
.DS_Store
*.cpython-37.opt-2.pyc
*.cpython-39-arm-linux-gnueabihf.so
*.
*.pyc
*/__pycache__
/.vscode
+16 -14
View File
@@ -881,14 +881,16 @@ class I4V4Z4T4DataDecoder(RecDataDecoder):
def decode(self, data: bytes) -> Optional[RecordingData]:
if len(data) < 18:
return None
voltage = 0
mem_cnt = data[1]
time_stamp: float = struct.unpack('<I', data[4:8])[0] # unit: ms 0x18030000
current = struct.unpack('<i', data[8:12])[0] # unit: nA
voltage = struct.unpack('<i', data[12:16])[0] # unit: uV
ch2 = struct.unpack('<i', data[12:16])[0] # unit: uV
impedance = struct.unpack('<i', data[16:20])[0] # unit: mOm
if self._mode == 16:
voltage = impedance - voltage
voltage = impedance - ch2
else:
voltage = ch2
cycle_number = struct.unpack('<H', data[20:22])[0]
finish_mode_falg = data[22]
@@ -948,18 +950,18 @@ class I4V4Z4T4DataDecoder(RecDataDecoder):
ret.append_data(1, voltage)
ret.append_data(2, impedance)
ret.append_data(3, cycle_number)
ret.append_data(4, battery)
ret.append_data(5, elite_notify_times)
ret.append_data(6, mem_cnt)
# ret.append_data(4, battery)
# ret.append_data(5, elite_notify_times)
# ret.append_data(6, mem_cnt)
# memoryboard information
ret.append_data(7, ram_num)
ret.append_data(8, broken_flag)
try:
ret.append_data(9, mem_wrong_information)
# print('append_data success, mem_wrong_information:', mem_wrong_information, hex(mem_wrong_information))
except:
print('append_data fail, mem_wrong_information:', mem_wrong_information, hex(mem_wrong_information))
# # memoryboard information
# ret.append_data(7, ram_num)
# ret.append_data(8, broken_flag)
# try:
# ret.append_data(9, mem_wrong_information)
# # print('append_data success, mem_wrong_information:', mem_wrong_information, hex(mem_wrong_information))
# except:
# print('append_data fail, mem_wrong_information:', mem_wrong_information, hex(mem_wrong_information))
+2
View File
@@ -76,6 +76,8 @@ class MultiExtMemSpiInterface(LowLevelHardwareInterface):
def set_pin_mem_req(self, value: bool):
channel = self.select
if self._pin_mem_req_value[channel] == value:
print('last_req_sig[channel] == value', channel, self._pin_mem_req_value[channel], value, datetime.now())
self.pin_mem_req.output(value)
self._pin_mem_req_value[channel] = value
+4 -4
View File
@@ -118,13 +118,13 @@ class Selector:
self._p2.output(p[2])
# if (value == 4 and self._last_sel != 6):
# print('mem_sel is not use gray code, value:', value, ', last value:', self._last_sel)
# print('mem_sel is not use gray code, value:', value, ', last value:', self._last_sel, datetime.now())
# elif (value == 5 and self._last_sel != 4):
# print('mem_sel is not use gray code, value:', value, ', last value:', self._last_sel)
# print('mem_sel is not use gray code, value:', value, ', last value:', self._last_sel, datetime.now())
# elif (value == 7 and self._last_sel != 5):
# print('mem_sel is not use gray code, value:', value, ', last value:', self._last_sel)
# print('mem_sel is not use gray code, value:', value, ', last value:', self._last_sel, datetime.now())
# elif (value == 6 and self._last_sel != 7):
# print('mem_sel is not use gray code, value:', value, ', last value:', self._last_sel)
# print('mem_sel is not use gray code, value:', value, ', last value:', self._last_sel, datetime.now())
self._last_sel = value
+13
View File
@@ -117,6 +117,9 @@ class DataServer(SocketServer, DataAPI):
self.database_process = DataBaseProcess('data_server', self.log_verbose, self._queue_db, self._queue_ds_dict, self._queue_msg)
self.database_process.start()
self._no_data_total_duration = 0
self._recv_memory_cost_time = 0
@logging_info
def setup(self):
self._available_channel.clear()
@@ -666,7 +669,17 @@ class DataServer(SocketServer, DataAPI):
print("q size= ", self._configurations[device]._queue_rec.qsize())
self._configurations[device].put_rec_queue(data)
self._no_data_total_duration = 0
ret = True
else:
time_diff = time() - self._recv_memory_cost_time
self._no_data_total_duration += time_diff
if self._no_data_total_duration > 1:
print('data is None', device, datetime.now(), self._no_data_total_duration)
print("sync.get_pin_mem_req() != sync.get_pin_ram_sel()")
print("no~", sync.select, sync.get_pin_mem_req(), sync.get_pin_ram_sel(), datetime.now())
print()
self._recv_memory_cost_time = time()
return ret
+18 -10
View File
@@ -105,6 +105,9 @@ class RecordingProcess(Process):
self._mem_tailer_len = 6
self._single_data_len = self._elite_data_len + self._mem_header_len + self._mem_tailer_len
self._decoder = self.data_format()
self._start_time = time()
def ensure_data_format(self) -> DataDecodeFormat:
if isinstance(self._data_format, (str, bytes)):
self._data_format = DataDecodeFormat.parse(self._data_format)
@@ -133,9 +136,9 @@ class RecordingProcess(Process):
decoder._prev_data = self._prev_data
decoder._prev_delta_time = self._prev_delta_time
decoder._prev_time_stamp = self._prev_time_stamp
# elif isinstance(decoder, I4V4Z4T4DataDecoder):
elif isinstance(decoder, I4V4Z4T4DataDecoder):
# get cycle_time from meta file
# decoder._mode = self._meta_file.configuration.MODE
decoder._mode = self._meta_file.configuration.get_parameter('MODE')
# decoder._cycle_start_time = self._cycle_start_time
elif isinstance(decoder, NeuliveThreeOneDataDecoder):
# get amp_gain from meta file
@@ -151,9 +154,8 @@ class RecordingProcess(Process):
decoder._prev_time_stamp = self._prev_time_stamp
elif isinstance(decoder, EISZeroOneDataDecoder):
# get amp_gain from meta file
decoder._ac_amp = self._meta_file.configuration.get_parameter('AC_AMP')
decoder._mode = self._meta_file.configuration.get_parameter('MODE')
decoder._ac_amp = self._meta_file.configuration.get_parameter('AC_AMP')
decoder._freq_start = self._meta_file.configuration.get_parameter('FREQ_START')
decoder._freq_stop = self._meta_file.configuration.get_parameter('FREQ_STOP')
@@ -200,14 +202,13 @@ class RecordingProcess(Process):
self._isTimeOut = True
self._timer = current_time
decoder = self.data_format()
# print('sync_data')
# print('data',data)
# print('server/data', self._prev_delta_time,self._prev_time_stamp, self._prev_data)
if data is None or len(data) == 0:
result = decoder.decode(b'')
result = self._decoder.decode(b'')
if result is not None:
ret = result
@@ -221,7 +222,7 @@ class RecordingProcess(Process):
for offset, section in self._foreach_data_section(data):
# for section in self._neu_foreach_data_section(data):
result = decoder.decode(section)
result = self._decoder.decode(section)
# if self._isTimeOut:
# try:
# print('result: ', result.data_size)
@@ -229,9 +230,15 @@ class RecordingProcess(Process):
# pass
try:
if isinstance(decoder, I4V4Z4T4DataDecoder) or isinstance(decoder, EISZeroOneDataDecoder):
if decoder.isFinishMode is not None and decoder.isFinishMode() == 1:
time_duration = self._meta_file.configuration.get_parameter('TIME_DURATION')
if time_duration and time_duration is not 0 and time() - self._start_time >= time_duration:
self._queue_msg.put(['ds', self._device, 'interrupt'])
return None
if isinstance(self._decoder, I4V4Z4T4DataDecoder) or isinstance(self._decoder, EISZeroOneDataDecoder):
if self._decoder.isFinishMode is not None and self._decoder.isFinishMode() == 1:
self._queue_msg.put(['ds', self._device, 'interrupt'])
return None
# content = {}
# content['header'] = 'device_instruction/0'
# content['device'] = result.device
@@ -350,7 +357,8 @@ class RecordingProcess(Process):
if colum_total == 1:
print('this ram data < 3 records, colum_total = ', colum_total)
print('raw_data[0]', list(raw_data[0]))
return save
save = True
# return save
elif colum_total == 2:
print('this ram data < 3 records, colum_total = ', colum_total)
+43 -30
View File
@@ -11,9 +11,21 @@
"constant": {
"FREQ_MAX": 4294967296,
"VOLT_MAX": 65536,
"BLE_WRITE_MAX": 255
"BLE_WRITE_MAX": 255,
"TIME_MAX": 100000
},
"parameters": {
"TIME_DURATION": {
"description": "Run duration",
"record_meta": true,
"initial": 0,
"domain": [
"TIME_MAX"
],
"value": {
"expression": "VALUE"
}
},
"CHANNEL": {
"derzteription": "record channels",
"record_meta": true,
@@ -48,9 +60,9 @@
"description": "working mode",
"record_meta": true,
"value": [
"EIS CURVE",
"Cyclic Voltammetry",
"Dev Mode"
"EIS CURVE",
"Cyclic Voltammetry",
"Dev Mode"
]
},
"FREQ_START": {
@@ -58,10 +70,10 @@
"record_meta": true,
"initial": 13422819,
"domain": [
"FREQ_MAX"
"FREQ_MAX"
],
"value": {
"expression": "VALUE"
"expression": "VALUE"
}
},
"FREQ_STOP": {
@@ -69,10 +81,10 @@
"record_meta": true,
"initial": 7,
"domain": [
"FREQ_MAX"
"FREQ_MAX"
],
"value": {
"expression": "VALUE"
"expression": "VALUE"
}
},
"DELAY": {
@@ -91,21 +103,21 @@
"record_meta": true,
"initial": 8,
"value": [
2,
4,
8,
16
2,
4,
8,
16
]
},
"DC_BIAS": {
"description": "DC voltage bias in mV",
"record_meta": true,
"initial": 15000,
"initial": 25000,
"domain": [
35001
"VOLT_MAX"
],
"value": {
"expression": "VALUE"
"expression": "VALUE"
}
},
"AC_AMP": {
@@ -113,7 +125,7 @@
"record_meta": true,
"initial": 25,
"domain": [
2048
2048
]
},
"SCALE": {
@@ -121,8 +133,8 @@
"record_meta": true,
"initial": 0,
"value": [
0,
1
0,
1
]
},
"PPD": {
@@ -130,7 +142,7 @@
"record_meta": true,
"initial": 10,
"domain": [
11
11
]
},
"RTIA": {
@@ -138,11 +150,11 @@
"record_meta": true,
"initial": 4,
"value": [
0,
1,
2,
3,
4
0,
1,
2,
3,
4
]
},
"ADC_VALUE_I": {
@@ -154,10 +166,10 @@
"record_meta": true,
"initial": 10000,
"domain": [
100001
100001
],
"value": {
"expression": "VALUE"
"expression": "VALUE"
}
},
"CTRL_HIGH_Z_15": {
@@ -242,9 +254,9 @@
"BLE_WRITE": {
"description": "send msg to elite",
"domain": {
"list": [
"list": [
"BLE_WRITE_MAX"
]
]
},
"initial": "[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]",
"value": "VALUE"
@@ -254,12 +266,13 @@
"domain": "int"
}
},
"instruction": {
"start": [
{
"expression": "MODE",
"when": {
"*": "start_data"
"*": "start_data"
}
}
],
@@ -430,4 +443,4 @@
"_cdr('20X>ADC_VALUE_I')"
]
}
}
}
+48 -2
View File
@@ -9,6 +9,7 @@
"minor_version_number": 6
},
"constant": {
"TIME_MAX": 100000,
"VOLT_MAX": 65536,
"Const_Current_Range": 1500001,
"BLE_WRITE_MAX": 255
@@ -686,6 +687,15 @@
"expression": "VALUE"
}
},
"CC_CP_SPEED": {
"description": "charge speed for CC and CP mode",
"initial": 1,
"value": [
"low",
"normal",
"high"
]
},
"ADC_LEVEL_I_15": {
"description": "ADC level",
"record_meta": true,
@@ -763,6 +773,17 @@
"s",
"ms"
]
},
"TIME_DURATION": {
"description": "Run duration",
"record_meta": true,
"initial": 0,
"domain": [
"TIME_MAX"
],
"value": {
"expression": "VALUE"
}
}
},
"instruction": {
@@ -849,7 +870,7 @@
"13": "curve_ocp",
"14": "curve_pulse_sensing",
"15": "curve_dpv",
"16": "curve_const_vscan"
"16": "curve_cp"
}
},
{
@@ -1047,6 +1068,7 @@
"vb": "Const_Current_value",
"vc": "VOLTSTOP_MAX",
"vd": "VOLTSTOP_MIN",
"ve": "CC_CP_SPEED",
"pa": "ADC_LEVEL_I_15",
"pb": "ADC_LEVEL_V_IN_15",
"pc": "DAC_LEVEL_V_OUT_15",
@@ -1058,7 +1080,31 @@
"B>va;4B>vb;2B>vc;2B>vd;",
"4b>pa;4b>pb;",
"4b>pc;4b>pd;",
"2B>pe"
"2B>pe;",
"4b>0b0001;4b>ve"
]
},
"curve_cp": {
"type": "RIS",
"parameter": {
"va": "Charge",
"vb": "Const_Current_value",
"vc": "VOLTSTOP_MAX",
"vd": "VOLTSTOP_MIN",
"ve": "CC_CP_SPEED",
"pa": "ADC_LEVEL_I_15",
"pb": "ADC_LEVEL_V_IN_15",
"pc": "DAC_LEVEL_V_OUT_15",
"pd": "CTRL_HIGH_Z_15",
"pe": "SAMPLE_RATE"
},
"data": [
"X07;",
"B>va;4B>vb;2B>vc;2B>vd;",
"4b>pa;4b>pb;",
"4b>pc;4b>pd;",
"2B>pe;",
"4b>0b0000;4b>ve"
]
},
"curve_cv3": {