Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ML
lib
Binary Storage
Commits
8a095870
Commit
8a095870
authored
Feb 13, 2020
by
Zhukov, Alexander P
Browse files
Troubleshooting incorrect recored table in the epilog
parent
33955d51
Changes
3
Hide whitespace changes
Inline
Side-by-side
.gitignore
View file @
8a095870
...
...
@@ -2,6 +2,7 @@
*.lvlps
/test.bin
/BPMDataRaw
/BCMData
/.idea
/venv
*.zip
...
...
py/read_seq.py
View file @
8a095870
...
...
@@ -8,12 +8,24 @@ Created on Mon Jan 27 16:11:06 2020
from
read_storage
import
BinaryStorage
# file = BinaryStorage('/data/BinStorage/BCMData/200210_1512_00110000_DCM.bin')
# file = BinaryStorage('/data/BinStorage/BCMData/200210_1538_00110000_DCM.bin')
file
=
BinaryStorage
(
'/data/BinStorage/test.bin'
)
def
show
(
record
):
if
'value'
in
record
:
value
=
record
[
'value'
]
record
[
'value'
]
=
value
[
0
]
print
(
record
)
while
True
:
record
=
file
.
read
()
if
'EOF'
in
record
:
break
print
(
record
)
show
(
record
)
print
(
'++++++++++++++++'
)
show
(
file
[
9
])
file
.
close
()
py/read_storage.py
View file @
8a095870
...
...
@@ -18,7 +18,7 @@ class BinaryStorage:
def
__init__
(
self
,
path
):
self
.
file
=
open
(
'/data/BinStorage/test.bin'
,
'rb'
)
self
.
file
=
open
(
path
,
'rb'
)
bytes
=
self
.
file
.
read
(
HEADER_SZ
)
# print(bytes.decode())
self
.
rec_table
=
read_epilog
(
self
.
file
)
...
...
@@ -184,7 +184,7 @@ def read_record(file):
while
True
:
field_type
=
read_byte
(
file
)
#
print('Field type', field_type, hex(field_type))
print
(
'Field type'
,
field_type
,
hex
(
field_type
))
func
=
parser
.
get
(
field_type
,
lambda
file
,
rec
:
True
)
result
=
func
(
file
,
record
)
if
not
result
:
...
...
@@ -198,13 +198,14 @@ def read_epilog(file):
raw
=
array
(
'I'
,
file
.
read
(
4
))
raw
.
byteswap
()
num_records
=
raw
[
0
]
print
(
num_records
)
file
.
seek
(
-
4
-
OFST_SIZE
*
num_records
,
os
.
SEEK_END
)
# the last record is EOF, and the very last offset has nothing
raw
=
array
(
'L'
,
file
.
read
(
OFST_SIZE
*
(
num_records
-
2
)))
raw
=
array
(
'L'
,
file
.
read
(
OFST_SIZE
*
(
num_records
-
2
)))
raw
.
byteswap
()
print
(
'Number of records: '
,
len
(
raw
))
# print(raw.itemsize)
#
print(raw)
print
(
raw
)
return
raw
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment