Can you answer the question? Here is still the long test example. It should not stay like this later...
I just want to use again a lot of our code that we have developed for other components. The base unit is also no more powerful than a Raspberry Pi.
https://cms-wind.de/news/unsere-cms-applikation/
from mcc_172_libs.daqhat import (
mcc172, HatIDs, SourceType, OptionFlags)
from mcc_172_libs.daqhats_utils import select_hat_device, chan_list_to_mask
from collections import deque
from time import sleep
def init_deque():
samples = deque(maxlen=3)
for i in range(2):
samples.append(i)
data = deque(maxlen=10)
# print(samples)
for _ in range(2):
data.append(deque(maxlen=10))
# print(data)
data_dict = {
'data': data,
'samples': samples,
'samples_count': 0
}
print(data_dict)
return data_dict
def init_hat():
channels = [0, 1]
iepe_enable = 1
sensitivity_val = 500 # mV/g
global _HAT
adress = select_hat_device(HatIDs.MCC_172)
hat = mcc172(adress)
hat.a_in_clock_config_write(SourceType.LOCAL, 51200)
channel_mask = 0x0
# print(channel_mask)
# hier ggf. gewünschte Länge der Anzeige
samples_to_buffer = int(5 * 1000)
for channel in channels:
channel_mask |= 1 << channel
hat.iepe_config_write(channel, iepe_enable)
hat.a_in_sensitivity_write(channel, sensitivity_val)
# hat.a_in_scan_start(channel_mask, samples_to_buffer, OptionFlags.CONTINUOUS)
return hat
def start_data(hat, data_dict):
channels = [0, 1]
ALL_AVAILABLE = -1
RETURN_IMMEDIATELY = 0
# data_dict = data_dict
sample_count = 0
while True:
data_dict = data_dict
hat.a_in_scan_start(3, 100, OptionFlags.CONTINUOUS)
read_result = hat.a_in_scan_read_numpy(100, RETURN_IMMEDIATELY)
read_data = read_result.data.reshape((len(channels), -1), order='F')
for channel in channels:
data_dict['data'][channel].extend(read_data[channels.index(channel)])
print(data_dict['data'][channel])
# print(data_dict['data'][channel][0][0])
hat.a_in_scan_stop()
hat.a_in_scan_cleanup()
sleep(0.5)
# return data_dict
test_dict = init_deque()
test_hat = init_hat()
test_data = start_data(test_hat, test_dict)