Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ML
lib
Binary Storage
Commits
790db7db
Commit
790db7db
authored
Jan 29, 2020
by
Zhukov, Alexander P
Browse files
[] now supports negative indices
parent
a89dfac5
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
LV/BinStorage.lvclass
View file @
790db7db
This diff is collapsed.
Click to expand it.
LV/BinaryStorage.lvproj
View file @
790db7db
<?xml version='1.0' encoding='UTF-8'?>
<Project
Type=
"Project"
LVVersion=
"18008000"
>
<Property
Name=
"CCSymbols"
Type=
"Str"
></Property>
<Property
Name=
"NI.LV.All.SourceOnly"
Type=
"Bool"
>
true
</Property>
<Property
Name=
"NI.Project.Description"
Type=
"Str"
></Property>
<Property
Name=
"SMProvider.SMVersion"
Type=
"Int"
>
201310
</Property>
<Item
Name=
"My Computer"
Type=
"My Computer"
>
<Property
Name=
"IOScan.Faults"
Type=
"Str"
></Property>
<Property
Name=
"IOScan.NetVarPeriod"
Type=
"UInt"
>
100
</Property>
<Property
Name=
"IOScan.NetWatchdogEnabled"
Type=
"Bool"
>
false
</Property>
<Property
Name=
"IOScan.Period"
Type=
"UInt"
>
10000
</Property>
<Property
Name=
"IOScan.PowerupMode"
Type=
"UInt"
>
0
</Property>
<Property
Name=
"IOScan.Priority"
Type=
"UInt"
>
9
</Property>
<Property
Name=
"IOScan.ReportModeConflict"
Type=
"Bool"
>
true
</Property>
<Property
Name=
"IOScan.StartEngineOnDeploy"
Type=
"Bool"
>
false
</Property>
<Property
Name=
"NI.SortType"
Type=
"Int"
>
3
</Property>
<Property
Name=
"server.app.propertiesEnabled"
Type=
"Bool"
>
true
</Property>
<Property
Name=
"server.control.propertiesEnabled"
Type=
"Bool"
>
true
</Property>
<Property
Name=
"server.tcp.enabled"
Type=
"Bool"
>
false
</Property>
<Property
Name=
"server.tcp.port"
Type=
"Int"
>
0
</Property>
<Property
Name=
"server.tcp.serviceName"
Type=
"Str"
>
My Computer/VI Server
</Property>
<Property
Name=
"server.tcp.serviceName.default"
Type=
"Str"
>
My Computer/VI Server
</Property>
<Property
Name=
"server.vi.callsEnabled"
Type=
"Bool"
>
true
</Property>
<Property
Name=
"server.vi.propertiesEnabled"
Type=
"Bool"
>
true
</Property>
<Property
Name=
"specify.custom.address"
Type=
"Bool"
>
false
</Property>
<Item
Name=
"TestStorage.vi"
Type=
"VI"
URL=
"../TestStorage.vi"
/>
<Item
Name=
"BinStorage.lvclass"
Type=
"LVClass"
URL=
"../BinStorage.lvclass"
/>
<Item
Name=
"Dependencies"
Type=
"Dependencies"
/>
<Item
Name=
"Build Specifications"
Type=
"Build"
/>
</Item>
</Project>
<?xml version='1.0' encoding='UTF-8'?>
<Project
Type=
"Project"
LVVersion=
"18008000"
>
<Property
Name=
"CCSymbols"
Type=
"Str"
></Property>
<Property
Name=
"NI.LV.All.SourceOnly"
Type=
"Bool"
>
true
</Property>
<Property
Name=
"NI.Project.Description"
Type=
"Str"
></Property>
<Property
Name=
"SMProvider.SMVersion"
Type=
"Int"
>
201310
</Property>
<Item
Name=
"My Computer"
Type=
"My Computer"
>
<Property
Name=
"IOScan.Faults"
Type=
"Str"
></Property>
<Property
Name=
"IOScan.NetVarPeriod"
Type=
"UInt"
>
100
</Property>
<Property
Name=
"IOScan.NetWatchdogEnabled"
Type=
"Bool"
>
false
</Property>
<Property
Name=
"IOScan.Period"
Type=
"UInt"
>
10000
</Property>
<Property
Name=
"IOScan.PowerupMode"
Type=
"UInt"
>
0
</Property>
<Property
Name=
"IOScan.Priority"
Type=
"UInt"
>
9
</Property>
<Property
Name=
"IOScan.ReportModeConflict"
Type=
"Bool"
>
true
</Property>
<Property
Name=
"IOScan.StartEngineOnDeploy"
Type=
"Bool"
>
false
</Property>
<Property
Name=
"NI.SortType"
Type=
"Int"
>
3
</Property>
<Property
Name=
"server.app.propertiesEnabled"
Type=
"Bool"
>
true
</Property>
<Property
Name=
"server.control.propertiesEnabled"
Type=
"Bool"
>
true
</Property>
<Property
Name=
"server.tcp.enabled"
Type=
"Bool"
>
false
</Property>
<Property
Name=
"server.tcp.port"
Type=
"Int"
>
0
</Property>
<Property
Name=
"server.tcp.serviceName"
Type=
"Str"
>
My Computer/VI Server
</Property>
<Property
Name=
"server.tcp.serviceName.default"
Type=
"Str"
>
My Computer/VI Server
</Property>
<Property
Name=
"server.vi.callsEnabled"
Type=
"Bool"
>
true
</Property>
<Property
Name=
"server.vi.propertiesEnabled"
Type=
"Bool"
>
true
</Property>
<Property
Name=
"specify.custom.address"
Type=
"Bool"
>
false
</Property>
<Item
Name=
"TestStorage.vi"
Type=
"VI"
URL=
"../TestStorage.vi"
/>
<Item
Name=
"BinStorage.lvclass"
Type=
"LVClass"
URL=
"../BinStorage.lvclass"
/>
<Item
Name=
"Dependencies"
Type=
"Dependencies"
/>
<Item
Name=
"Build Specifications"
Type=
"Build"
/>
</Item>
</Project>
py/read_random.py
View file @
790db7db
...
...
@@ -7,12 +7,14 @@ Created on Mon Jan 27 16:14:52 2020
"""
from
read_storage
import
*
from
read_storage
import
BinaryStorage
file
=
open
(
'/data/BinStorage/test.bin'
,
'rb'
)
bytes
=
file
.
read
(
12
)
print
(
bytes
.
decode
())
#
file = open('/data/BinStorage/test.bin','rb')
#
bytes = file.read(12)
#
print(bytes.decode())
read_epilog
(
file
)
file
=
BinaryStorage
(
'/data/BinStorage/test.bin'
)
print
(
file
[
0
])
file
.
close
()
\ No newline at end of file
py/read_sequeintial.py
deleted
100755 → 0
View file @
a89dfac5
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Jan 27 16:11:06 2020
@author: az9
"""
from
read_storage
import
BinaryStorage
# file = open('/data/BinStorage/test.bin','rb')
# bytes = file.read(12)
# print(bytes.decode())
file
=
BinaryStorage
(
'/data/BinStorage/test.bin'
)
while
True
:
record
=
file
.
read_record
()
if
'EOF'
in
record
:
break
print
(
record
)
file
.
close
()
\ No newline at end of file
py/read_storage.py
View file @
790db7db
...
...
@@ -11,11 +11,16 @@ import os
class
BinaryStorage
:
HEADER_SZ
=
12
def
__init__
(
self
,
path
):
self
.
file
=
open
(
'/data/BinStorage/test.bin'
,
'rb'
)
bytes
=
self
.
file
.
read
(
12
)
print
(
bytes
.
decode
())
bytes
=
self
.
file
.
read
(
BinaryStorage
.
HEADER_SZ
)
# print(bytes.decode())
self
.
rec_table
=
BinaryStorage
.
read_epilog
(
self
.
file
)
self
.
file
.
seek
(
BinaryStorage
.
HEADER_SZ
)
def
close
(
self
):
...
...
@@ -24,6 +29,14 @@ class BinaryStorage:
def
read
(
self
):
return
BinaryStorage
.
read_record
(
self
.
file
)
def
__getitem__
(
self
,
key
):
offset
=
self
.
rec_table
[
key
]
self
.
file
.
seek
(
offset
)
return
BinaryStorage
.
read_record
(
self
.
file
)
def
__len__
(
self
):
return
len
(
self
.
rec_table
)
...
...
@@ -164,21 +177,22 @@ class BinaryStorage:
if
not
result
:
break
return
record
def
read_epilog
(
file
):
OFST_SIZE
=
8
file
.
seek
(
-
4
,
os
.
SEEK_END
)
raw
=
array
(
'I'
,
file
.
read
(
4
))
raw
.
byteswap
()
num_records
=
raw
[
0
]
num_records
=
raw
[
0
]
print
(
num_records
)
file
.
seek
(
-
4
-
OFST_SIZE
*
num_records
,
os
.
SEEK_END
)
raw
=
array
(
'L'
,
file
.
read
(
OFST_SIZE
*
num_records
))
raw
.
byteswap
()
print
(
raw
.
itemsize
)
print
(
raw
)
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
.
byteswap
()
# print(raw.itemsize)
#
print(raw
)
return
raw
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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