Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
DaqIOLib
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
CI / CD
CI / CD
Pipelines
Schedules
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
NADS-Public
DaqIOLib
Commits
6253ccbd
Commit
6253ccbd
authored
Mar 23, 2005
by
yiannis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added support for variable size channels.
parent
44fe2a09
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
73 additions
and
9 deletions
+73
-9
DaqFileIO.cxx
DaqFileIO.cxx
+73
-9
No files found.
DaqFileIO.cxx
View file @
6253ccbd
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
///
///
// DAQ low level IO Library
// DAQ low level IO Library
//
//
// $Id: DaqFileIO.cxx,v 1.
9 2005/03/14 23:05:04
yiannis Exp $
// $Id: DaqFileIO.cxx,v 1.
10 2005/03/22 20:12:17
yiannis Exp $
// Date: March, 2005
// Date: March, 2005
// Author: Yiannis Papelis
// Author: Yiannis Papelis
//
//
...
@@ -982,8 +982,24 @@ CDaqLowLevelIo::CheckIntegrity(
...
@@ -982,8 +982,24 @@ CDaqLowLevelIo::CheckIntegrity(
}
}
else
{
else
{
CDaqChannelInfo
&
ch
=
m_Channels
[
chId
];
CDaqChannelInfo
&
ch
=
m_Channels
[
chId
];
int
skip
=
ch
.
GetRecSize
();
int
skip
;
fseek
(
m_pFile
,
skip
,
SEEK_CUR
);
if
(
ch
.
IsVarLen
()
)
{
int
actCount
;
if
(
fread
(
&
actCount
,
sizeof
(
int
),
1
,
m_pFile
)
!=
1
)
{
sprintf
(
buf
,
"Could not read var size channel length; chId=%d, ofs=%d, abort"
,
chId
,
ftell
(
m_pFile
));
m_LastError
=
buf
;
(
*
m_UserErrorFunc
)(
m_Filename
.
c_str
(),
buf
);
return
false
;
}
skip
=
ch
.
GetItemSize
()
*
actCount
;
}
else
{
skip
=
ch
.
GetRecSize
();
}
if
(
skip
)
fseek
(
m_pFile
,
skip
,
SEEK_CUR
);
// save a system call if 0
}
}
ch
++
;
ch
++
;
...
@@ -1235,9 +1251,24 @@ CDaqLowLevelIo::LowLevelDataRead(
...
@@ -1235,9 +1251,24 @@ CDaqLowLevelIo::LowLevelDataRead(
m_LastError
=
buf
;
m_LastError
=
buf
;
return
false
;
return
false
;
}
}
CDaqChannelInfo
&
ch
=
m_Channels
[
chId
];
CDaqChannelInfo
&
ch
=
m_Channels
[
chId
];
int
size
=
ch
.
GetRecSize
();
int
size
;
if
(
ch
.
IsVarLen
()
)
{
int
actCount
;
if
(
fread
(
&
actCount
,
sizeof
(
int
),
1
,
m_pFile
)
!=
1
)
{
sprintf
(
buf
,
"Could not read var size channel length; chId=%d, ofs=%d, abort"
,
chId
,
ftell
(
m_pFile
));
m_LastError
=
buf
;
(
*
m_UserErrorFunc
)(
m_Filename
.
c_str
(),
buf
);
return
false
;
}
size
=
ch
.
GetItemSize
()
*
actCount
;
}
else
{
size
=
ch
.
GetRecSize
();
}
if
(
needChan
[
chId
]
!=
-
1
)
{
// it is -1 when we don't need it
if
(
needChan
[
chId
]
!=
-
1
)
{
// it is -1 when we don't need it
CDaqBuffer
&
daqBuf
=
userStorage
[
needChan
[
chId
]];
CDaqBuffer
&
daqBuf
=
userStorage
[
needChan
[
chId
]];
...
@@ -1247,6 +1278,7 @@ CDaqLowLevelIo::LowLevelDataRead(
...
@@ -1247,6 +1278,7 @@ CDaqLowLevelIo::LowLevelDataRead(
return
false
;
return
false
;
}
}
if
(
size
>
0
)
{
size_t
n
=
fread
(
pTempSpace
,
size
,
1
,
m_pFile
);
size_t
n
=
fread
(
pTempSpace
,
size
,
1
,
m_pFile
);
if
(
n
!=
1
)
{
if
(
n
!=
1
)
{
sprintf
(
buf
,
"read data for channel %d near frame %d failed"
,
sprintf
(
buf
,
"read data for channel %d near frame %d failed"
,
...
@@ -1254,12 +1286,21 @@ CDaqLowLevelIo::LowLevelDataRead(
...
@@ -1254,12 +1286,21 @@ CDaqLowLevelIo::LowLevelDataRead(
m_LastError
=
buf
;
m_LastError
=
buf
;
return
false
;
return
false
;
}
}
daqBuf
.
Append
(
pTempSpace
,
size
,
ch
.
GetItemCount
());
}
// for variable size records, 'size' may be less than the full size for the channel
// The shorter storage used in the DAQ is transparent to the user so we fill
// the rest of the space (that didn't get read from the file with zeros.
int
fullSize
=
ch
.
GetRecSize
();
if
(
fullSize
!=
size
)
{
memset
(((
char
*
)
pTempSpace
)
+
size
,
0
,
fullSize
-
size
);
}
daqBuf
.
Append
(
pTempSpace
,
fullSize
,
ch
.
GetItemCount
());
if
(
pFrameList
)
(
*
pFrameList
)[
needChan
[
chId
]].
push_back
(
curFrame
);
if
(
pFrameList
)
(
*
pFrameList
)[
needChan
[
chId
]].
push_back
(
curFrame
);
}
}
else
{
else
{
// skip the data
// skip the data
fseek
(
m_pFile
,
size
,
SEEK_CUR
);
if
(
size
)
fseek
(
m_pFile
,
size
,
SEEK_CUR
);
}
}
}
}
}
}
...
@@ -1785,7 +1826,23 @@ CDaqLowLevelIo::ReadDataForOneFrame(
...
@@ -1785,7 +1826,23 @@ CDaqLowLevelIo::ReadDataForOneFrame(
}
}
CDaqChannelInfo
&
ch
=
m_Channels
[
chId
];
CDaqChannelInfo
&
ch
=
m_Channels
[
chId
];
int
size
=
ch
.
GetRecSize
();
int
size
;
if
(
ch
.
IsVarLen
()
)
{
int
actCount
;
if
(
fread
(
&
actCount
,
sizeof
(
int
),
1
,
m_pFile
)
!=
1
)
{
sprintf
(
buf
,
"Could not read var size channel length; chId=%d, ofs=%d, abort"
,
chId
,
ftell
(
m_pFile
));
m_LastError
=
buf
;
(
*
m_UserErrorFunc
)(
m_Filename
.
c_str
(),
buf
);
return
eDAQ_READ_ERROR
;
}
size
=
ch
.
GetItemSize
()
*
actCount
;
}
else
{
size
=
ch
.
GetRecSize
();
}
if
(
needChannel
[
chId
]
!=
-
1
)
{
// it is -1 when we don't need it
if
(
needChannel
[
chId
]
!=
-
1
)
{
// it is -1 when we don't need it
CDaqBuffer
&
daqBuf
=
storage
[
needChannel
[
chId
]];
CDaqBuffer
&
daqBuf
=
storage
[
needChannel
[
chId
]];
...
@@ -1795,13 +1852,20 @@ CDaqLowLevelIo::ReadDataForOneFrame(
...
@@ -1795,13 +1852,20 @@ CDaqLowLevelIo::ReadDataForOneFrame(
return
eDAQ_READ_INTERNAL_ERROR
;
return
eDAQ_READ_INTERNAL_ERROR
;
}
}
if
(
size
>
0
)
{
size_t
n
=
fread
(
pTempSpace
,
size
,
1
,
m_pFile
);
size_t
n
=
fread
(
pTempSpace
,
size
,
1
,
m_pFile
);
if
(
n
!=
1
)
{
if
(
n
!=
1
)
{
sprintf
(
buf
,
"read data for channel %d failed"
,
chId
);
sprintf
(
buf
,
"read data for channel %d failed"
,
chId
);
m_LastError
=
buf
;
m_LastError
=
buf
;
return
eDAQ_READ_ERROR
;
return
eDAQ_READ_ERROR
;
}
}
daqBuf
.
Replace
(
pTempSpace
,
size
,
ch
.
GetItemCount
());
}
int
fullSize
=
ch
.
GetRecSize
();
if
(
fullSize
!=
size
)
{
memset
(((
char
*
)
pTempSpace
)
+
size
,
0
,
fullSize
-
size
);
}
daqBuf
.
Replace
(
pTempSpace
,
fullSize
,
ch
.
GetItemCount
());
gotData
[
chId
]
=
true
;
gotData
[
chId
]
=
true
;
}
}
else
{
else
{
...
...
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