Commit 35d329fe authored by thaag's avatar thaag
Browse files

- try to replace hardware driver

- new route: replace interface to hardware
parent c6c84d26
......@@ -8,12 +8,17 @@ import logging
import dug_seis.acquisition.hardware_driver.regs as regs
import dug_seis.acquisition.hardware_driver.spcerr as err
from ctypes import byref, c_int32
from dug_seis.acquisition.one_card_std_init import init_card as sdt_init_card
from dug_seis.acquisition.hardware_driver.pyspcm import spcm_dwSetParam_i32, spcm_dwGetParam_i32, spcm_vClose
if True:
print("Simulating hardware")
else:
print("Running on real hardware")
from dug_seis.acquisition.hardware_driver.pyspcm import spcm_dwSetParam_i32, spcm_dwGetParam_i32, spcm_vClose
from ctypes import byref, c_int32
class Card:
......@@ -31,6 +36,7 @@ class Card:
"""Initialise card. Setup card parameters. Reserve buffers for DMA data transfer."""
logging.info("init card: {}\n".format(self.card_nr))
if self.card_nr == 0 or self.card_nr == 1:
print(sdt_init_card(param, self.card_nr))
self.h_card, self.pv_buffer = sdt_init_card(param, self.card_nr)
else:
logging.error("card_nr needs to be 0 or 1, received:{}".format(self.card_nr))
......
......@@ -5,14 +5,19 @@
import logging
import dug_seis.acquisition.hardware_driver.regs as regs
from dug_seis.acquisition.hardware_driver.pyspcm import spcm_hOpen, spcm_dwGetParam_i32
from dug_seis.acquisition.hardware_driver.pyspcm import spcm_dwSetParam_i32, spcm_dwGetContBuf_i64
from dug_seis.acquisition.hardware_driver.pyspcm import spcm_dwDefTransfer_i64
from dug_seis.acquisition.hardware_driver.pyspcm import SPCM_BUF_DATA, SPCM_DIR_CARDTOPC
from ctypes import c_int32, c_uint64
from ctypes import create_string_buffer, byref, c_void_p
if True:
print("Simulating hardware")
from dug_seis.acquisition.simulated_hardware import spcm_hOpen, spcm_dwGetParam_i32
else:
print("Running on real hardware")
from dug_seis.acquisition.hardware_driver.pyspcm import spcm_hOpen, spcm_dwGetParam_i32
from dug_seis.acquisition.hardware_driver.pyspcm import spcm_dwSetParam_i32, spcm_dwGetContBuf_i64
from dug_seis.acquisition.hardware_driver.pyspcm import spcm_dwDefTransfer_i64
from dug_seis.acquisition.hardware_driver.pyspcm import SPCM_BUF_DATA, SPCM_DIR_CARDTOPC
def sz_type_to_name(l_card_type):
"""sz_type_to_name: doing name translation."""
......
from ctypes import byref
def spcm_hOpen(dev):
print("simulating {}".format(dev))
return "card", "buffer"
def spcm_dwGetParam_i32(h_card, reg, card_type):
print(card_type)
......@@ -11,12 +11,16 @@ stop and synchronise the cards.
import logging
import dug_seis.acquisition.hardware_driver.regs as regs
from dug_seis.acquisition.hardware_driver.pyspcm import spcm_hOpen, spcm_dwSetParam_i32, spcm_dwGetParam_i32
from dug_seis.acquisition.hardware_driver.pyspcm import spcm_dwGetErrorInfo_i32, spcm_vClose
from ctypes import create_string_buffer, byref
from ctypes import c_int32
if True:
print("Simulating hardware")
else:
print("Running on real hardware")
from dug_seis.acquisition.hardware_driver.pyspcm import spcm_hOpen, spcm_dwSetParam_i32, spcm_dwGetParam_i32
from dug_seis.acquisition.hardware_driver.pyspcm import spcm_dwGetErrorInfo_i32, spcm_vClose
class StarHub:
def __init__(self):
......
2018-11-13 17:22:08,225 INFO DUG-Seis started
2018-11-13 17:22:08,245 INFO Acquisition script started
2018-11-13 17:22:08,245 INFO init card: 0
2018-11-13 17:22:08,246 ERROR card 0 not found...
2018-11-13 17:22:08,247 ERROR card 0 not found...
2018-11-13 17:23:26,441 INFO DUG-Seis started
2018-11-13 17:23:26,459 INFO Acquisition script started
2018-11-13 17:23:26,459 INFO init card: 0
2018-11-13 17:25:01,023 INFO DUG-Seis started
2018-11-13 17:25:01,041 INFO Acquisition script started
2018-11-13 17:25:01,041 INFO init card: 0
2018-11-14 13:39:00,987 INFO DUG-Seis started
2018-11-14 13:39:01,007 INFO Acquisition script started
2018-11-14 13:39:01,007 INFO init card: 0
2018-11-14 13:39:01,008 ERROR Card: unknown type sn 00000 not supported by example
2018-11-14 13:39:01,011 ERROR Card: unknown type sn 00000 not supported by example
2018-11-14 13:42:55,184 INFO DUG-Seis started
2018-11-14 13:42:55,202 INFO Acquisition script started
2018-11-14 13:42:55,203 INFO init card: 0
2018-11-14 13:42:55,204 ERROR Card: unknown type sn 00000 not supported by example
2018-11-14 13:42:55,206 ERROR Card: unknown type sn 00000 not supported by example
2018-11-14 14:03:57,058 INFO DUG-Seis started
2018-11-14 14:03:57,075 INFO Acquisition script started
2018-11-14 14:03:57,075 INFO init card: 0
2018-11-14 14:03:57,076 ERROR Card: unknown type sn 00000 not supported by example
2018-11-14 14:03:57,078 ERROR Card: unknown type sn 00000 not supported by example
from ctypes import c_int32, byref, cast, POINTER, pointer, addressof
def f(x):
x._obj.value = 55
print("in func: {}".format(x._obj.value))
l_card_type = c_int32(99)
"""
print(l_card_type)
print(type(l_card_type))
print(byref(l_card_type))
print(type(byref(l_card_type)))
print(l_card_type.value)
print(type(l_card_type.value))
"""
f(byref(l_card_type))
print(byref(l_card_type))
pc = pointer(l_card_type)
pc.contents.value = 77 # or pc[0] = 77
print("{}".format(pc.contents.value))
print(byref(pc))
print(addressof(pc))
print(l_card_type.value)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment