mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-04 00:50:42 +02:00
added defines for python (#498)
This commit is contained in:
parent
f1051246ad
commit
3d3e70c718
@ -29,6 +29,7 @@ set( PYTHON_FILES
|
||||
decorators.py
|
||||
detector_property.py
|
||||
detector.py
|
||||
defines.py
|
||||
eiger.py
|
||||
enums.py
|
||||
errors.py
|
||||
|
@ -11,7 +11,7 @@ enums.cpp
|
||||
import re
|
||||
import subprocess
|
||||
|
||||
from parse import remove_comments
|
||||
from parse import remove_comments, remove_ifdefs
|
||||
|
||||
|
||||
allow_bitwise_op = ["streamingInterface", "M3_GainCaps"]
|
||||
@ -98,25 +98,25 @@ def generate_enum_string(enums):
|
||||
return ''.join(data)
|
||||
|
||||
|
||||
def remove_ifdefs(lines):
|
||||
"""Keeps C++ version of the code"""
|
||||
out = []
|
||||
it = iter(lines)
|
||||
skip = False
|
||||
for line in it:
|
||||
# def remove_ifdefs(lines):
|
||||
# """Keeps C++ version of the code"""
|
||||
# out = []
|
||||
# it = iter(lines)
|
||||
# skip = False
|
||||
# for line in it:
|
||||
|
||||
if "#ifdef __cplusplus" in line:
|
||||
line = next(it)
|
||||
# if "#ifdef __cplusplus" in line:
|
||||
# line = next(it)
|
||||
|
||||
if "#else" in line:
|
||||
skip = True
|
||||
# if "#else" in line:
|
||||
# skip = True
|
||||
|
||||
if "#endif" in line:
|
||||
skip = False
|
||||
# if "#endif" in line:
|
||||
# skip = False
|
||||
|
||||
if not skip and "#endif" not in line:
|
||||
out.append(line)
|
||||
return out
|
||||
# if not skip and "#endif" not in line:
|
||||
# out.append(line)
|
||||
# return out
|
||||
|
||||
|
||||
with open('../../slsSupportLib/include/sls/sls_detector_defs.h') as f:
|
||||
|
30
python/scripts/generate_pydef.py
Normal file
30
python/scripts/generate_pydef.py
Normal file
@ -0,0 +1,30 @@
|
||||
|
||||
|
||||
import re
|
||||
import subprocess
|
||||
|
||||
from parse import remove_comments, remove_ifdefs
|
||||
|
||||
with open('../../slsSupportLib/include/sls/sls_detector_defs.h') as f:
|
||||
data = f.read()
|
||||
|
||||
data = remove_comments(data)
|
||||
data = data.splitlines()
|
||||
# data = remove_ifdefs(data)
|
||||
|
||||
|
||||
ignore = ['#define MYROOT', '#define __cplusplus']
|
||||
|
||||
defines = {}
|
||||
for i, line in enumerate(data):
|
||||
if line.startswith('#define') and line not in ignore:
|
||||
_, name, value = line.split(maxsplit = 2)
|
||||
print(f'{name}={value}')
|
||||
defines[name]=value
|
||||
|
||||
|
||||
warning = '#WARINING This file is auto generated any edits might be overwritten without warning\n\n'
|
||||
with open('../slsdet/defines.py', 'w') as f:
|
||||
f.write(warning)
|
||||
for key, value in defines.items():
|
||||
f.write(f'{key}={value}\n')
|
@ -25,7 +25,25 @@ def remove_comments(text):
|
||||
)
|
||||
return re.sub(pattern, replacer, text)
|
||||
|
||||
def remove_ifdefs(lines):
|
||||
"""Keeps C++ version of the code"""
|
||||
out = []
|
||||
it = iter(lines)
|
||||
skip = False
|
||||
for line in it:
|
||||
|
||||
if "#ifdef __cplusplus" in line:
|
||||
line = next(it)
|
||||
|
||||
if "#else" in line:
|
||||
skip = True
|
||||
|
||||
if "#endif" in line:
|
||||
skip = False
|
||||
|
||||
if not skip and "#endif" not in line:
|
||||
out.append(line)
|
||||
return out
|
||||
|
||||
|
||||
#based on ccsyspath: https://github.com/AndrewWalker/ccsyspath
|
||||
|
@ -17,8 +17,9 @@ import _slsdet
|
||||
xy = _slsdet.xy
|
||||
defs = _slsdet.slsDetectorDefs
|
||||
|
||||
#Make enums and #defines available at top level
|
||||
from .enums import *
|
||||
|
||||
from .defines import *
|
||||
|
||||
IpAddr = _slsdet.IpAddr
|
||||
MacAddr = _slsdet.MacAddr
|
||||
|
29
python/slsdet/defines.py
Normal file
29
python/slsdet/defines.py
Normal file
@ -0,0 +1,29 @@
|
||||
#WARINING This file is auto generated any edits might be overwritten without warning
|
||||
|
||||
BIT32_MASK=0xFFFFFFFF
|
||||
MAX_RX_DBIT=64
|
||||
DEFAULT_PORTNO=1952
|
||||
DEFAULT_UDP_PORTNO=50001
|
||||
DEFAULT_ZMQ_CL_PORTNO=30001
|
||||
DEFAULT_ZMQ_RX_PORTNO=30001
|
||||
DEFAULT_UDP_SRC_PORTNO=32410
|
||||
DEFAULT_UDP_DST_PORTNO=50001
|
||||
MAX_UDP_DESTINATION=32
|
||||
SLS_DETECTOR_HEADER_VERSION=0x2
|
||||
SLS_DETECTOR_JSON_HEADER_VERSION=0x4
|
||||
UDP_PACKET_DATA_BYTES=(1344)
|
||||
MAX_TRIMEN=100
|
||||
MAX_BLACKFIN_PROGRAM_SIZE=(128 * 1024)
|
||||
GET_FLAG=-1
|
||||
DEFAULT_DET_MAC="00:aa:bb:cc:dd:ee"
|
||||
DEFAULT_DET_IP="129.129.202.45"
|
||||
DEFAULT_DET_MAC2="00:aa:bb:cc:dd:ff"
|
||||
DEFAULT_DET_IP2="129.129.202.46"
|
||||
LOCALHOST_IP="127.0.0.1"
|
||||
MAX_STR_LENGTH=1000
|
||||
SHORT_STR_LENGTH=20
|
||||
MAX_PATTERN_LENGTH=0x2000
|
||||
DEFAULT_STREAMING_TIMER_IN_MS=500
|
||||
NUM_RX_THREAD_IDS=9
|
||||
MAX_NUM_PACKETS=512
|
||||
TRIMBITMASK=0x3f
|
Loading…
x
Reference in New Issue
Block a user