Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
proview
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Esteban Blanc
proview
Commits
7b057e27
Commit
7b057e27
authored
May 27, 2005
by
claes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changes for objectoriented profibus IO
parent
ac787549
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
574 additions
and
504 deletions
+574
-504
src/lib/rt/src/os_linux/rt_io_m_pb_module.c
src/lib/rt/src/os_linux/rt_io_m_pb_module.c
+101
-0
src/lib/rt/src/rt_io_base.c
src/lib/rt/src/rt_io_base.c
+468
-504
src/lib/rt/src/rt_io_base.h
src/lib/rt/src/rt_io_base.h
+5
-0
No files found.
src/lib/rt/src/os_linux/rt_io_m_pb_module.c
0 → 100644
View file @
7b057e27
/* rt_io_m_pb_ai.c
PROVIEW/R */
#pragma pack(1)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <math.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include "pb_type.h"
#include "pb_if.h"
#include "pb_fmb.h"
#include "pb_dp.h"
#include "rt_io_pb_locals.h"
#include "pwr.h"
#include "pwr_baseclasses.h"
#include "rt_io_base.h"
#include "rt_io_msg.h"
#include "rt_errh.h"
#include "rt_io_profiboard.h"
/*----------------------------------------------------------------------------*\
Init method for the Pb module
\*----------------------------------------------------------------------------*/
static
pwr_tStatus
IoCardInit
(
io_tCtx
ctx
,
io_sAgent
*
ap
,
io_sRack
*
rp
,
io_sCard
*
cp
)
{
printf
(
"Method Pb_Module-IoCardInit
\n
"
);
return
IO__SUCCESS
;
}
/*----------------------------------------------------------------------------*\
Read method for the Pb module
\*----------------------------------------------------------------------------*/
static
pwr_tStatus
IoCardRead
(
io_tCtx
ctx
,
io_sAgent
*
ap
,
io_sRack
*
rp
,
io_sCard
*
cp
)
{
printf
(
"Method Pb_Module-IoCardRead
\n
"
);
return
IO__SUCCESS
;
}
/*----------------------------------------------------------------------------*\
Write method for the Pb module
\*----------------------------------------------------------------------------*/
static
pwr_tStatus
IoCardWrite
(
io_tCtx
ctx
,
io_sAgent
*
ap
,
io_sRack
*
rp
,
io_sCard
*
cp
)
{
printf
(
"Method Pb_Module-IoCardWrite
\n
"
);
return
IO__SUCCESS
;
}
/*----------------------------------------------------------------------------*\
Close method for the Pb module
\*----------------------------------------------------------------------------*/
static
pwr_tStatus
IoCardClose
(
io_tCtx
ctx
,
io_sAgent
*
ap
,
io_sRack
*
rp
,
io_sCard
*
cp
)
{
printf
(
"Method Pb_Module-IoCardClose
\n
"
);
return
IO__SUCCESS
;
}
/*----------------------------------------------------------------------------*\
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport
pwr_BindIoMethods
(
Pb_Module
)
=
{
pwr_BindIoMethod
(
IoCardInit
),
pwr_BindIoMethod
(
IoCardRead
),
pwr_BindIoMethod
(
IoCardWrite
),
pwr_BindIoMethod
(
IoCardClose
),
pwr_NullMethod
};
src/lib/rt/src/rt_io_base.c
View file @
7b057e27
...
@@ -58,6 +58,7 @@ pwr_dImport pwr_BindIoMethods(Co_PI24BO);
...
@@ -58,6 +58,7 @@ pwr_dImport pwr_BindIoMethods(Co_PI24BO);
pwr_dImport
pwr_BindIoMethods
(
Co_CO4uP
);
// Share methods with PI24BO
pwr_dImport
pwr_BindIoMethods
(
Co_CO4uP
);
// Share methods with PI24BO
pwr_dImport
pwr_BindIoMethods
(
Pb_Profiboard
);
pwr_dImport
pwr_BindIoMethods
(
Pb_Profiboard
);
pwr_dImport
pwr_BindIoMethods
(
Pb_DP_Slave
);
pwr_dImport
pwr_BindIoMethods
(
Pb_DP_Slave
);
pwr_dImport
pwr_BindIoMethods
(
Pb_Module
);
pwr_dImport
pwr_BindIoMethods
(
Pb_Di
);
pwr_dImport
pwr_BindIoMethods
(
Pb_Di
);
pwr_dImport
pwr_BindIoMethods
(
Pb_Do
);
pwr_dImport
pwr_BindIoMethods
(
Pb_Do
);
pwr_dImport
pwr_BindIoMethods
(
Pb_Ai
);
pwr_dImport
pwr_BindIoMethods
(
Pb_Ai
);
...
@@ -78,6 +79,7 @@ pwr_BindIoClasses(Base) = {
...
@@ -78,6 +79,7 @@ pwr_BindIoClasses(Base) = {
pwr_BindIoClass
(
Co_CO4uP
),
pwr_BindIoClass
(
Co_CO4uP
),
pwr_BindIoClass
(
Pb_Profiboard
),
pwr_BindIoClass
(
Pb_Profiboard
),
pwr_BindIoClass
(
Pb_DP_Slave
),
pwr_BindIoClass
(
Pb_DP_Slave
),
pwr_BindIoClass
(
Pb_Module
),
pwr_BindIoClass
(
Pb_Di
),
pwr_BindIoClass
(
Pb_Di
),
pwr_BindIoClass
(
Pb_Do
),
pwr_BindIoClass
(
Pb_Do
),
pwr_BindIoClass
(
Pb_Ai
),
pwr_BindIoClass
(
Pb_Ai
),
...
@@ -1066,131 +1068,145 @@ static pwr_tStatus io_FindMethods(
...
@@ -1066,131 +1068,145 @@ static pwr_tStatus io_FindMethods(
pwr_tStatus
(
**
Write
)
()
pwr_tStatus
(
**
Write
)
()
)
)
{
{
char
cname
[
80
];
int
found
;
int
found
;
pwr_tStatus
sts
;
pwr_tStatus
sts
;
int
i
,
j
;
int
i
,
j
,
k
;
char
*
s
;
char
*
s
;
char
init_methodstr
[
80
];
char
methodstr
[
80
];
char
close_methodstr
[
80
];
char
classstr
[
80
];
char
read_methodstr
[
80
];
pwr_tOName
methodobject
;
char
write_methodstr
[
80
];
pwr_sMethod
info
;
pwr_tStatus
(
*
method
)
();
/* Detect name of methods to look for */
int
next
;
switch
(
type
)
pwr_tCid
cid
;
{
case
io_eType_Agent
:
if
(
Init
)
strcpy
(
init_methodstr
,
"IoAgentInit"
);
*
Init
=
0
;
strcpy
(
close_methodstr
,
"IoAgentClose"
);
if
(
Close
)
strcpy
(
read_methodstr
,
"IoAgentRead"
);
*
Close
=
0
;
strcpy
(
write_methodstr
,
"IoAgentWrite"
);
if
(
Read
)
break
;
*
Read
=
0
;
case
io_eType_Rack
:
if
(
Write
)
strcpy
(
init_methodstr
,
"IoRackInit"
);
*
Write
=
0
;
strcpy
(
close_methodstr
,
"IoRackClose"
);
strcpy
(
read_methodstr
,
"IoRackRead"
);
for
(
k
=
0
;
k
<
4
;
k
++
)
{
strcpy
(
write_methodstr
,
"IoRackWrite"
);
// Init, Close, Read, Write loop
break
;
cid
=
class
;
case
io_eType_Card
:
next
=
0
;
strcpy
(
init_methodstr
,
"IoCardInit"
);
while
(
1
)
{
strcpy
(
close_methodstr
,
"IoCardClose"
);
// Super class loop, inherit methods from superclass
strcpy
(
read_methodstr
,
"IoCardRead"
);
strcpy
(
write_methodstr
,
"IoCardWrite"
);
sts
=
gdh_ObjidToName
(
cdh_ClassIdToObjid
(
cid
),
methodobject
,
sizeof
(
methodobject
),
break
;
cdh_mName_volumeStrict
);
default:
if
(
EVEN
(
sts
))
return
sts
;
return
IO__NOMETHOD
;
}
sts
=
gdh_ObjidToName
(
cdh_ClassIdToObjid
(
class
),
cname
,
sizeof
(
cname
),
/* Detect name of methods to look for */
cdh_mName_object
);
switch
(
type
)
{
if
(
EVEN
(
sts
))
return
sts
;
case
io_eType_Agent
:
strcat
(
methodobject
,
"-IoMethods-IoAgent"
);
break
;
case
io_eType_Rack
:
strcat
(
methodobject
,
"-IoMethods-IoRack"
);
break
;
case
io_eType_Card
:
strcat
(
methodobject
,
"-IoMethods-IoCard"
);
break
;
default:
return
IO__NOMETHOD
;
}
switch
(
k
)
{
case
0
:
strcat
(
methodobject
,
"Init"
);
break
;
case
1
:
strcat
(
methodobject
,
"Close"
);
break
;
case
2
:
strcat
(
methodobject
,
"Read"
);
break
;
case
3
:
strcat
(
methodobject
,
"Write"
);
break
;
}
/* Why does cdh_mName_object return the path ? */
sts
=
gdh_GetObjectInfo
(
methodobject
,
&
info
,
sizeof
(
info
));
if
(
(
s
=
strrchr
(
cname
,
'-'
))
!=
0
)
if
(
ODD
(
sts
))
{
strcpy
(
cname
,
++
s
);
strcpy
(
classstr
,
info
.
MethodName
);
if
(
(
s
=
strchr
(
classstr
,
'-'
)))
{
if
(
strcmp
(
cname
,
"$Node"
)
==
0
)
strcpy
(
methodstr
,
s
+
1
);
strcpy
(
cname
,
"Node"
);
*
s
=
0
;
}
if
(
Init
!=
NULL
)
break
;
*
Init
=
NULL
;
if
(
Read
!=
NULL
)
*
Read
=
NULL
;
if
(
Write
!=
NULL
)
*
Write
=
NULL
;
if
(
Close
!=
NULL
)
*
Close
=
NULL
;
found
=
0
;
/* Search i IoUser methods */
for
(
i
=
0
;;
i
++
)
{
if
(
pwr_gUser_IoUserClassMethods
[
i
].
ClassName
[
0
]
==
'\0'
)
break
;
{
if
(
strcmp
(
pwr_gUser_IoUserClassMethods
[
i
].
ClassName
,
cname
)
==
0
)
{
for
(
j
=
0
;;
j
++
)
{
found
=
1
;
if
((
*
pwr_gUser_IoUserClassMethods
[
i
].
Methods
)[
j
].
MethodName
[
0
]
==
'\0'
)
break
;
if
(
Init
!=
NULL
&&
strcmp
(
(
*
pwr_gUser_IoUserClassMethods
[
i
].
Methods
)[
j
].
MethodName
,
init_methodstr
)
==
0
)
*
Init
=
(
*
pwr_gUser_IoUserClassMethods
[
i
].
Methods
)[
j
].
Method
;
else
if
(
Close
!=
NULL
&&
strcmp
(
(
*
pwr_gUser_IoUserClassMethods
[
i
].
Methods
)[
j
].
MethodName
,
close_methodstr
)
==
0
)
*
Close
=
(
*
pwr_gUser_IoUserClassMethods
[
i
].
Methods
)[
j
].
Method
;
else
if
(
Read
!=
NULL
&&
strcmp
(
(
*
pwr_gUser_IoUserClassMethods
[
i
].
Methods
)[
j
].
MethodName
,
read_methodstr
)
==
0
)
*
Read
=
(
*
pwr_gUser_IoUserClassMethods
[
i
].
Methods
)[
j
].
Method
;
else
if
(
Write
!=
NULL
&&
strcmp
(
(
*
pwr_gUser_IoUserClassMethods
[
i
].
Methods
)[
j
].
MethodName
,
write_methodstr
)
==
0
)
*
Write
=
(
*
pwr_gUser_IoUserClassMethods
[
i
].
Methods
)[
j
].
Method
;
}
}
}
if
(
found
)
sts
=
gdh_GetSuperClass
(
cid
,
&
cid
);
if
(
EVEN
(
sts
))
{
next
=
1
;
break
;
break
;
}
}
}
}
if
(
next
)
if
(
!
found
)
continue
;
{
for
(
i
=
0
;;
i
++
)
method
=
0
;
{
found
=
0
;
if
(
pwr_gBase_IoClassMethods
[
i
].
ClassName
[
0
]
==
'\0'
)
break
;
/* Search i IoUser methods */
for
(
i
=
0
;;
i
++
)
{
if
(
pwr_gUser_IoUserClassMethods
[
i
].
ClassName
[
0
]
==
'\0'
)
break
;
{
{
if
(
strcmp
(
pwr_gBase_IoClassMethods
[
i
].
ClassName
,
cname
)
==
0
)
if
(
strcmp
(
pwr_gUser_IoUserClassMethods
[
i
].
ClassName
,
classstr
)
==
0
)
{
{
for
(
j
=
0
;;
j
++
)
{
for
(
j
=
0
;;
j
++
)
{
found
=
1
;
found
=
1
;
if
((
*
pwr_gBase_Io
ClassMethods
[
i
].
Methods
)[
j
].
MethodName
[
0
]
==
'\0'
)
if
((
*
pwr_gUser_IoUser
ClassMethods
[
i
].
Methods
)[
j
].
MethodName
[
0
]
==
'\0'
)
break
;
break
;
if
(
Init
!=
NULL
&&
if
(
strcmp
(
(
*
pwr_gUser_IoUserClassMethods
[
i
].
Methods
)[
j
].
MethodName
,
strcmp
(
(
*
pwr_gBase_IoClassMethods
[
i
].
Methods
)[
j
].
MethodName
,
methodstr
)
==
0
)
init_methodstr
)
==
0
)
method
=
(
*
pwr_gUser_IoUserClassMethods
[
i
].
Methods
)[
j
].
Method
;
*
Init
=
(
*
pwr_gBase_IoClassMethods
[
i
].
Methods
)[
j
].
Method
;
else
if
(
Close
!=
NULL
&&
strcmp
(
(
*
pwr_gBase_IoClassMethods
[
i
].
Methods
)[
j
].
MethodName
,
close_methodstr
)
==
0
)
*
Close
=
(
*
pwr_gBase_IoClassMethods
[
i
].
Methods
)[
j
].
Method
;
else
if
(
Read
!=
NULL
&&
strcmp
(
(
*
pwr_gBase_IoClassMethods
[
i
].
Methods
)[
j
].
MethodName
,
read_methodstr
)
==
0
)
*
Read
=
(
*
pwr_gBase_IoClassMethods
[
i
].
Methods
)[
j
].
Method
;
else
if
(
Write
!=
NULL
&&
strcmp
(
(
*
pwr_gBase_IoClassMethods
[
i
].
Methods
)[
j
].
MethodName
,
write_methodstr
)
==
0
)
*
Write
=
(
*
pwr_gBase_IoClassMethods
[
i
].
Methods
)[
j
].
Method
;
}
}
}
}
if
(
found
)
if
(
found
)
break
;
break
;
}
}
}
}
if
(
!
found
)
{
for
(
i
=
0
;;
i
++
)
{
if
(
pwr_gBase_IoClassMethods
[
i
].
ClassName
[
0
]
==
'\0'
)
break
;
if
(
strcmp
(
pwr_gBase_IoClassMethods
[
i
].
ClassName
,
classstr
)
==
0
)
{
for
(
j
=
0
;;
j
++
)
{
found
=
1
;
if
((
*
pwr_gBase_IoClassMethods
[
i
].
Methods
)[
j
].
MethodName
[
0
]
==
'\0'
)
break
;
if
(
strcmp
(
(
*
pwr_gBase_IoClassMethods
[
i
].
Methods
)[
j
].
MethodName
,
methodstr
)
==
0
)
method
=
(
*
pwr_gBase_IoClassMethods
[
i
].
Methods
)[
j
].
Method
;
}
}
if
(
found
)
break
;
}
}
switch
(
k
)
{
case
0
:
if
(
Init
)
*
Init
=
method
;
break
;
case
1
:
if
(
Close
)
*
Close
=
method
;
break
;
case
2
:
if
(
Read
)
*
Read
=
method
;
break
;
case
3
:
if
(
Write
)
*
Write
=
method
;
break
;
}
}
}
if
(
!
found
)
if
(
!
found
)
return
IO__NOMETHOD
;
return
IO__NOMETHOD
;
...
@@ -1207,111 +1223,87 @@ pwr_tStatus io_GetIoTypeClasses(
...
@@ -1207,111 +1223,87 @@ pwr_tStatus io_GetIoTypeClasses(
int
*
size
int
*
size
)
)
{
{
pwr_tStatus
sts
;
pwr_tStatus
sts
;
int
i
,
j
;
pwr_sClassDef
cdef
;
char
init_methodstr
[
80
];
pwr_tOid
oid
;
char
close_methodstr
[
80
];
int
add_class
;
char
read_methodstr
[
80
];
pwr_sAttrRef
aref
;
char
write_methodstr
[
80
];
*
size
=
0
;
/* Detect name of methods to look for */
*
classes
=
calloc
(
IO_CLASSES_SIZE
,
sizeof
(
pwr_tCid
));
switch
(
type
)
{
for
(
sts
=
gdh_GetClassList
(
pwr_eClass_ClassDef
,
&
oid
);
ODD
(
sts
);
sts
=
gdh_GetNextObject
(
oid
,
&
oid
))
{
aref
=
cdh_ObjidToAref
(
oid
);
sts
=
gdh_GetObjectInfoAttrref
(
&
aref
,
&
cdef
,
sizeof
(
cdef
));
if
(
EVEN
(
sts
))
return
sts
;
add_class
=
0
;
switch
(
type
)
{
case
io_eType_Agent
:
case
io_eType_Agent
:
strcpy
(
init_methodstr
,
"IoAgentInit"
);
if
(
cdef
.
Flags
.
b
.
IOAgent
)
strcpy
(
close_methodstr
,
"IoAgentClose"
);
add_class
=
1
;
strcpy
(
read_methodstr
,
"IoAgentRead"
);
strcpy
(
write_methodstr
,
"IoAgentWrite"
);
break
;
break
;
case
io_eType_Rack
:
case
io_eType_Rack
:
strcpy
(
init_methodstr
,
"IoRackInit"
);
if
(
cdef
.
Flags
.
b
.
IORack
)
strcpy
(
close_methodstr
,
"IoRackClose"
);
add_class
=
1
;
strcpy
(
read_methodstr
,
"IoRackRead"
);
strcpy
(
write_methodstr
,
"IoRackWrite"
);
break
;
break
;
case
io_eType_Card
:
case
io_eType_Card
:
strcpy
(
init_methodstr
,
"IoCardInit"
);
if
(
cdef
.
Flags
.
b
.
IOCard
)
strcpy
(
close_methodstr
,
"IoCardClose"
);
add_class
=
1
;
strcpy
(
read_methodstr
,
"IoCardRead"
);
strcpy
(
write_methodstr
,
"IoCardWrite"
);
break
;
break
;
default:
default:
return
IO__NOMETHOD
;
return
IO__NOMETHOD
;
}
*
size
=
0
;
*
classes
=
calloc
(
IO_CLASSES_SIZE
,
sizeof
(
pwr_tClassId
));
/* Search i IoUser methods */
for
(
i
=
0
;;
i
++
)
{
if
(
pwr_gUser_IoUserClassMethods
[
i
].
ClassName
[
0
]
==
'\0'
)
break
;
for
(
j
=
0
;;
j
++
)
{
if
((
*
pwr_gUser_IoUserClassMethods
[
i
].
Methods
)[
j
].
MethodName
[
0
]
==
'\0'
)
break
;
if
(
(
strcmp
(
(
*
pwr_gUser_IoUserClassMethods
[
i
].
Methods
)[
j
].
MethodName
,
init_methodstr
)
==
0
)
||
(
strcmp
(
(
*
pwr_gUser_IoUserClassMethods
[
i
].
Methods
)[
j
].
MethodName
,
close_methodstr
)
==
0
)
||
(
strcmp
(
(
*
pwr_gUser_IoUserClassMethods
[
i
].
Methods
)[
j
].
MethodName
,
read_methodstr
)
==
0
)
||
(
strcmp
(
(
*
pwr_gUser_IoUserClassMethods
[
i
].
Methods
)[
j
].
MethodName
,
write_methodstr
)
==
0
))
{
/* This is a class of the desired type, insert in list */
if
(
*
size
>=
IO_CLASSES_SIZE
)
return
IO__CLASSEXCEED
;
sts
=
gdh_ClassNameToId
(
pwr_gUser_IoUserClassMethods
[
i
].
ClassName
,
&
(
*
classes
)[
*
size
]);
if
(
ODD
(
sts
))
(
*
size
)
++
;
break
;
}
}
}
}
/* Search i IoBase methods */
for
(
i
=
0
;;
i
++
)
{
if
(
pwr_gBase_IoClassMethods
[
i
].
ClassName
[
0
]
==
'\0'
)
break
;
for
(
j
=
0
;;
j
++
)
if
(
add_class
)
{
{
if
(
*
size
>=
IO_CLASSES_SIZE
)
if
((
*
pwr_gBase_IoClassMethods
[
i
].
Methods
)[
j
].
MethodName
[
0
]
==
'\0'
)
return
IO__CLASSEXCEED
;
break
;
if
(
(
strcmp
(
(
*
pwr_gBase_IoClassMethods
[
i
].
Methods
)[
j
].
MethodName
,
init_methodstr
)
==
0
)
||
(
strcmp
(
(
*
pwr_gBase_IoClassMethods
[
i
].
Methods
)[
j
].
MethodName
,
close_methodstr
)
==
0
)
||
(
strcmp
(
(
*
pwr_gBase_IoClassMethods
[
i
].
Methods
)[
j
].
MethodName
,
read_methodstr
)
==
0
)
||
(
strcmp
(
(
*
pwr_gBase_IoClassMethods
[
i
].
Methods
)[
j
].
MethodName
,
write_methodstr
)
==
0
))
{
/* This is a class of the desired type, insert in list */
if
(
*
size
>=
IO_CLASSES_SIZE
)
return
IO__CLASSEXCEED
;
if
(
strcmp
(
pwr_gBase_IoClassMethods
[
i
].
ClassName
,
"Node"
)
==
0
)
(
*
classes
)[
*
size
]
=
cdh_ClassObjidToId
(
oid
);
sts
=
gdh_ClassNameToId
(
"$Node"
,
(
*
size
)
++
;
&
(
*
classes
)[
*
size
]);
else
sts
=
gdh_ClassNameToId
(
pwr_gBase_IoClassMethods
[
i
].
ClassName
,
&
(
*
classes
)[
*
size
]);
if
(
ODD
(
sts
))
(
*
size
)
++
;
break
;
}
}
}
}
}
return
IO__SUCCESS
;
return
IO__SUCCESS
;
}
}
/*----------------------------------------------------------------------------*\
Check if class is an IO-type.
\*----------------------------------------------------------------------------*/
int
io_CheckClassIoType
(
io_eType
type
,
pwr_tCid
cid
)
{
pwr_tStatus
sts
;
pwr_sClassDef
cdef
;
pwr_sAttrRef
aref
;
aref
=
cdh_ObjidToAref
(
cdh_ClassIdToObjid
(
cid
));
sts
=
gdh_GetObjectInfoAttrref
(
&
aref
,
&
cdef
,
sizeof
(
cdef
));
if
(
EVEN
(
sts
))
return
0
;
switch
(
type
)
{
case
io_eType_Agent
:
if
(
cdef
.
Flags
.
b
.
IOAgent
)
return
1
;
break
;
case
io_eType_Rack
:
if
(
cdef
.
Flags
.
b
.
IORack
)
return
1
;
break
;
case
io_eType_Card
:
if
(
cdef
.
Flags
.
b
.
IOCard
)
return
1
;
break
;
default:
;
}
return
0
;
}
/*----------------------------------------------------------------------------*\
/*----------------------------------------------------------------------------*\
Insert a card object into the context list.
Insert a card object into the context list.
...
@@ -1351,107 +1343,99 @@ static pwr_tStatus io_init_card(
...
@@ -1351,107 +1343,99 @@ static pwr_tStatus io_init_card(
sts
=
gdh_GetObjectClass
(
objid
,
&
class
);
sts
=
gdh_GetObjectClass
(
objid
,
&
class
);
if
(
EVEN
(
sts
))
return
sts
;
if
(
EVEN
(
sts
))
return
sts
;
sts
=
io_FindMethods
(
class
,
io_eType_Card
,
if
(
io_CheckClassIoType
(
io_eType_Card
,
class
))
{
&
CardInit
,
&
CardClose
,
&
CardRead
,
&
CardWrite
);
sts
=
io_FindMethods
(
class
,
io_eType_Card
,
if
(
ODD
(
sts
))
&
CardInit
,
&
CardClose
,
&
CardRead
,
&
CardWrite
);
{
if
(
ODD
(
sts
))
{
if
(
CardInit
!=
NULL
||
CardClose
!=
NULL
||
CardRead
!=
NULL
||
CardWrite
!=
NULL
)
if
(
CardInit
!=
NULL
||
CardClose
!=
NULL
||
CardRead
!=
NULL
||
CardWrite
!=
NULL
)
{
{
/* This is a card object */
/* This is a card object */
/* Check if the rack should be handled by this process */
/* Check if the rack should be handled by this process */
sts
=
gdh_ObjidToName
(
objid
,
cname
,
sizeof
(
cname
),
sts
=
gdh_ObjidToName
(
objid
,
cname
,
sizeof
(
cname
),
cdh_mName_volumeStrict
);
cdh_mName_volumeStrict
);
if
(
EVEN
(
sts
))
return
sts
;
if
(
EVEN
(
sts
))
return
sts
;
ok
=
0
;
ok
=
0
;
strcpy
(
attrname
,
cname
);
strcpy
(
attrname
,
cname
);
strcat
(
attrname
,
".Process"
);
strcat
(
attrname
,
".Process"
);
sts
=
gdh_GetObjectInfo
(
attrname
,
&
process
,
sizeof
(
process
));
sts
=
gdh_GetObjectInfo
(
attrname
,
&
process
,
sizeof
(
process
));
if
(
(
EVEN
(
sts
)
&&
ctx
->
Process
==
io_mProcess_User
)
||
if
(
(
EVEN
(
sts
)
&&
ctx
->
Process
==
io_mProcess_User
)
||
(
ODD
(
sts
)
&&
ctx
->
Process
==
(
int
)
process
))
(
ODD
(
sts
)
&&
ctx
->
Process
==
(
int
)
process
))
{
{
if
(
process
==
io_mProcess_Plc
)
{
if
(
process
==
io_mProcess_Plc
)
/* Check thread also */
{
strcpy
(
attrname
,
cname
);
/* Check thread also */
strcat
(
attrname
,
".ThreadObject"
);
strcpy
(
attrname
,
cname
);
sts
=
gdh_GetObjectInfo
(
attrname
,
&
thread
,
sizeof
(
thread
));
strcat
(
attrname
,
".ThreadObject"
);
if
(
ODD
(
sts
)
&&
cdh_ObjidIsEqual
(
thread
,
ctx
->
Thread
))
sts
=
gdh_GetObjectInfo
(
attrname
,
&
thread
,
sizeof
(
thread
));
ok
=
1
;
if
(
ODD
(
sts
)
&&
cdh_ObjidIsEqual
(
thread
,
ctx
->
Thread
))
}
else
ok
=
1
;
ok
=
1
;
}
}
else
ok
=
1
;
}
if
(
ok
)
if
(
ok
)
{
{
/* Tread this card in this process */
/* Tread this card in this process */
strcpy
(
attrname
,
cname
);
strcpy
(
attrname
,
cname
);
strcat
(
attrname
,
".MaxNoOfChannels"
);
strcat
(
attrname
,
".MaxNoOfChannels"
);
sts
=
gdh_GetObjectInfo
(
attrname
,
&
maxchan
,
sizeof
(
maxchan
));
sts
=
gdh_GetObjectInfo
(
attrname
,
&
maxchan
,
sizeof
(
maxchan
));
if
(
EVEN
(
sts
))
{
if
(
EVEN
(
sts
))
strcpy
(
attrname
,
cname
);
{
strcat
(
attrname
,
".MaxNoOfCounters"
);
strcpy
(
attrname
,
cname
);
sts
=
gdh_GetObjectInfo
(
attrname
,
&
maxchan
,
sizeof
(
maxchan
));
strcat
(
attrname
,
".MaxNoOfCounters"
);
if
(
EVEN
(
sts
))
sts
=
gdh_GetObjectInfo
(
attrname
,
&
maxchan
,
sizeof
(
maxchan
));
maxchan
=
IO_CHANLIST_SIZE
;
if
(
EVEN
(
sts
))
}
maxchan
=
IO_CHANLIST_SIZE
;
}
cp
=
calloc
(
1
,
sizeof
(
io_sCard
));
cp
->
chanlist
=
(
io_sChannel
*
)
calloc
(
maxchan
,
sizeof
(
io_sChannel
));
cp
->
ChanListSize
=
maxchan
;
cp
->
Class
=
class
;
cp
->
Local
=
NULL
;
cp
->
Objid
=
objid
;
strcpy
(
cp
->
Name
,
cname
);
if
(
CardRead
!=
NULL
)
cp
->
Action
|=
io_mAction_Read
;
if
(
CardWrite
!=
NULL
)
cp
->
Action
|=
io_mAction_Write
;
cp
->
Init
=
CardInit
;
cp
->
Close
=
CardClose
;
cp
->
Read
=
CardRead
;
cp
->
Write
=
CardWrite
;
if
(
agent_type
==
io_eType_Agent
)
cp
->
AgentControlled
=
1
;
memset
(
&
attrref
,
0
,
sizeof
(
attrref
));
attrref
.
Objid
=
objid
;
sts
=
gdh_DLRefObjectInfoAttrref
(
&
attrref
,
(
void
*
)
&
cp
->
op
,
&
cp
->
Dlid
);
if
(
EVEN
(
sts
))
return
sts
;
strcpy
(
attrname
,
cname
);
strcat
(
attrname
,
".ScanTime"
);
sts
=
gdh_GetObjectInfo
(
attrname
,
&
scantime
,
sizeof
(
scantime
));
if
(
ODD
(
sts
))
cp
->
scan_interval
=
scantime
/
ctx
->
ScanTime
+
FLT_EPSILON
;
else
cp
->
scan_interval
=
1
;
/* Insert last in cardlist */
if
(
rp
->
cardlist
==
NULL
)
rp
->
cardlist
=
cp
;
else
{
for
(
clp
=
rp
->
cardlist
;
clp
->
next
!=
NULL
;
clp
=
clp
->
next
)
;
clp
->
next
=
cp
;
}
/* Fill in the channel and signal lists */
sts
=
gdh_GetChild
(
objid
,
&
chan
);
cp
=
calloc
(
1
,
sizeof
(
io_sCard
));
while
(
ODD
(
sts
))
cp
->
chanlist
=
(
io_sChannel
*
)
calloc
(
maxchan
,
sizeof
(
io_sChannel
));
{
cp
->
ChanListSize
=
maxchan
;
cp
->
Class
=
class
;
cp
->
Local
=
NULL
;
cp
->
Objid
=
objid
;
strcpy
(
cp
->
Name
,
cname
);
if
(
CardRead
!=
NULL
)
cp
->
Action
|=
io_mAction_Read
;
if
(
CardWrite
!=
NULL
)
cp
->
Action
|=
io_mAction_Write
;
cp
->
Init
=
CardInit
;
cp
->
Close
=
CardClose
;
cp
->
Read
=
CardRead
;
cp
->
Write
=
CardWrite
;
if
(
agent_type
==
io_eType_Agent
)
cp
->
AgentControlled
=
1
;
memset
(
&
attrref
,
0
,
sizeof
(
attrref
));
memset
(
&
attrref
,
0
,
sizeof
(
attrref
));
attrref
.
Objid
=
chan
;
attrref
.
Objid
=
objid
;
sts
=
gdh_DLRefObjectInfoAttrref
(
&
attrref
,
(
void
*
)
&
chan_op
,
&
chandlid
);
sts
=
gdh_DLRefObjectInfoAttrref
(
&
attrref
,
(
void
*
)
&
cp
->
op
,
&
cp
->
Dlid
);
if
(
EVEN
(
sts
))
return
sts
;
sts
=
gdh_GetObjectClass
(
chan
,
&
class
);
if
(
EVEN
(
sts
))
return
sts
;
if
(
EVEN
(
sts
))
return
sts
;
strcpy
(
attrname
,
cname
);
strcat
(
attrname
,
".ScanTime"
);
sts
=
gdh_GetObjectInfo
(
attrname
,
&
scantime
,
sizeof
(
scantime
));
if
(
ODD
(
sts
))
cp
->
scan_interval
=
scantime
/
ctx
->
ScanTime
+
FLT_EPSILON
;
else
cp
->
scan_interval
=
1
;
/* Insert last in cardlist */
if
(
rp
->
cardlist
==
NULL
)
rp
->
cardlist
=
cp
;
else
{
for
(
clp
=
rp
->
cardlist
;
clp
->
next
!=
NULL
;
clp
=
clp
->
next
)
;
clp
->
next
=
cp
;
}
/* Fill in the channel and signal lists */
switch
(
class
)
sts
=
gdh_GetChild
(
objid
,
&
chan
);
{
while
(
ODD
(
sts
))
{
memset
(
&
attrref
,
0
,
sizeof
(
attrref
));
attrref
.
Objid
=
chan
;
sts
=
gdh_DLRefObjectInfoAttrref
(
&
attrref
,
(
void
*
)
&
chan_op
,
&
chandlid
);
if
(
EVEN
(
sts
))
return
sts
;
sts
=
gdh_GetObjectClass
(
chan
,
&
class
);
if
(
EVEN
(
sts
))
return
sts
;
switch
(
class
)
{
case
pwr_cClass_ChanAi
:
case
pwr_cClass_ChanAi
:
sigchancon
=
((
pwr_sClass_ChanAi
*
)
chan_op
)
->
SigChanCon
.
Objid
;
sigchancon
=
((
pwr_sClass_ChanAi
*
)
chan_op
)
->
SigChanCon
.
Objid
;
number
=
((
pwr_sClass_ChanAi
*
)
chan_op
)
->
Number
;
number
=
((
pwr_sClass_ChanAi
*
)
chan_op
)
->
Number
;
...
@@ -1488,57 +1472,52 @@ static pwr_tStatus io_init_card(
...
@@ -1488,57 +1472,52 @@ static pwr_tStatus io_init_card(
sts
=
gdh_DLUnrefObjectInfo
(
chandlid
);
sts
=
gdh_DLUnrefObjectInfo
(
chandlid
);
sts
=
gdh_GetNextSibling
(
chan
,
&
chan
);
sts
=
gdh_GetNextSibling
(
chan
,
&
chan
);
continue
;
continue
;
}
}
if
(
(
int
)
number
>
maxchan
-
1
)
if
(
(
int
)
number
>
maxchan
-
1
)
{
{
/* Number out of range */
/* Number out of range */
errh_Error
(
errh_Error
(
"IO init error: number out of range %s, chan nr %d"
,
"IO init error: number out of range %s, chan nr %d"
,
cp
->
Name
,
number
);
cp
->
Name
,
number
);
sts
=
gdh_DLUnrefObjectInfo
(
chandlid
);
sts
=
gdh_DLUnrefObjectInfo
(
chandlid
);
sts
=
gdh_GetNextSibling
(
chan
,
&
chan
);
sts
=
gdh_GetNextSibling
(
chan
,
&
chan
);
continue
;
continue
;
}
}
/* Find signal */
/* Find signal */
if
(
cdh_ObjidIsNull
(
sigchancon
))
{
if
(
cdh_ObjidIsNull
(
sigchancon
))
/* Not connected */
{
sts
=
gdh_DLUnrefObjectInfo
(
chandlid
);
/* Not connected */
sts
=
gdh_GetNextSibling
(
chan
,
&
chan
);
sts
=
gdh_DLUnrefObjectInfo
(
chandlid
);
continue
;
sts
=
gdh_GetNextSibling
(
chan
,
&
chan
);
}
continue
;
}
sts
=
gdh_GetObjectClass
(
sigchancon
,
&
sigclass
);
if
(
EVEN
(
sts
))
{
sts
=
gdh_GetObjectClass
(
sigchancon
,
&
sigclass
);
sts
=
gdh_DLUnrefObjectInfo
(
chandlid
);
if
(
EVEN
(
sts
))
sts
=
gdh_GetNextSibling
(
chan
,
&
chan
);
{
continue
;
sts
=
gdh_DLUnrefObjectInfo
(
chandlid
);
}
sts
=
gdh_GetNextSibling
(
chan
,
&
chan
);
continue
;
}
memset
(
&
attrref
,
0
,
sizeof
(
attrref
));
memset
(
&
attrref
,
0
,
sizeof
(
attrref
));
attrref
.
Objid
=
sigchancon
;
attrref
.
Objid
=
sigchancon
;
sts
=
gdh_DLRefObjectInfoAttrref
(
&
attrref
,
(
void
*
)
&
sig_op
,
&
sigdlid
);
sts
=
gdh_DLRefObjectInfoAttrref
(
&
attrref
,
(
void
*
)
&
sig_op
,
&
sigdlid
);
if
(
EVEN
(
sts
))
if
(
EVEN
(
sts
))
{
{
sts
=
gdh_DLUnrefObjectInfo
(
chandlid
);
sts
=
gdh_DLUnrefObjectInfo
(
chandlid
);
sts
=
gdh_GetNextSibling
(
chan
,
&
chan
);
sts
=
gdh_GetNextSibling
(
chan
,
&
chan
);
continue
;
continue
;
}
}
/* Insert */
/* Insert */
chanp
=
&
cp
->
chanlist
[
number
];
chanp
=
&
cp
->
chanlist
[
number
];
chanp
->
cop
=
chan_op
;
chanp
->
cop
=
chan_op
;
chanp
->
ChanDlid
=
chandlid
;
chanp
->
ChanDlid
=
chandlid
;
chanp
->
ChanObjid
=
chan
;
chanp
->
ChanObjid
=
chan
;
chanp
->
sop
=
sig_op
;
chanp
->
sop
=
sig_op
;
chanp
->
SigDlid
=
sigdlid
;
chanp
->
SigDlid
=
sigdlid
;
chanp
->
SigObjid
=
sigchancon
;
chanp
->
SigObjid
=
sigchancon
;
chanp
->
ChanClass
=
class
;
chanp
->
ChanClass
=
class
;
chanp
->
SigClass
=
sigclass
;
chanp
->
SigClass
=
sigclass
;
switch
(
sigclass
)
switch
(
sigclass
)
{
{
case
pwr_cClass_Di
:
case
pwr_cClass_Di
:
chanp
->
vbp
=
gdh_TranslateRtdbPointer
(
chanp
->
vbp
=
gdh_TranslateRtdbPointer
(
(
pwr_tUInt32
)
((
pwr_sClass_Di
*
)
sig_op
)
->
ActualValue
);
(
pwr_tUInt32
)
((
pwr_sClass_Di
*
)
sig_op
)
->
ActualValue
);
...
@@ -1580,14 +1559,15 @@ static pwr_tStatus io_init_card(
...
@@ -1580,14 +1559,15 @@ static pwr_tStatus io_init_card(
sts
=
gdh_DLUnrefObjectInfo
(
chandlid
);
sts
=
gdh_DLUnrefObjectInfo
(
chandlid
);
sts
=
gdh_DLUnrefObjectInfo
(
sigdlid
);
sts
=
gdh_DLUnrefObjectInfo
(
sigdlid
);
memset
(
chanp
,
0
,
sizeof
(
*
chanp
));
memset
(
chanp
,
0
,
sizeof
(
*
chanp
));
}
}
/* If the signal has a Sup-object as a child, this will be inserted
/* If the signal has a Sup-object as a child, this will be inserted
in the suplist */
in the suplist */
/* if ( process != io_mProcess_Plc) */
/* if ( process != io_mProcess_Plc) */
io_ConnectToSupLst
(
ctx
->
SupCtx
,
sigclass
,
sigchancon
,
sig_op
);
io_ConnectToSupLst
(
ctx
->
SupCtx
,
sigclass
,
sigchancon
,
sig_op
);
sts
=
gdh_GetNextSibling
(
chan
,
&
chan
);
sts
=
gdh_GetNextSibling
(
chan
,
&
chan
);
}
}
}
}
}
}
}
...
@@ -1611,10 +1591,6 @@ static pwr_tStatus io_init_rack(
...
@@ -1611,10 +1591,6 @@ static pwr_tStatus io_init_rack(
pwr_tStatus
(
*
RackClose
)
();
pwr_tStatus
(
*
RackClose
)
();
pwr_tStatus
(
*
RackRead
)
();
pwr_tStatus
(
*
RackRead
)
();
pwr_tStatus
(
*
RackWrite
)
();
pwr_tStatus
(
*
RackWrite
)
();
pwr_tStatus
(
*
AgentInit
)
();
pwr_tStatus
(
*
AgentClose
)
();
pwr_tStatus
(
*
AgentRead
)
();
pwr_tStatus
(
*
AgentWrite
)
();
char
rname
[
140
];
char
rname
[
140
];
char
attrname
[
140
];
char
attrname
[
140
];
pwr_tUInt32
process
=
0
;
pwr_tUInt32
process
=
0
;
...
@@ -1628,98 +1604,90 @@ static pwr_tStatus io_init_rack(
...
@@ -1628,98 +1604,90 @@ static pwr_tStatus io_init_rack(
sts
=
gdh_GetObjectClass
(
objid
,
&
class
);
sts
=
gdh_GetObjectClass
(
objid
,
&
class
);
if
(
EVEN
(
sts
))
return
sts
;
if
(
EVEN
(
sts
))
return
sts
;
if
(
agent_type
==
io_eType_Node
)
if
(
agent_type
==
io_eType_Node
)
{
{
/* If this is an agent object, ignore this object and the descendents */
/* If this is an agent object, ignore this object and the descendents */
sts
=
io_FindMethods
(
class
,
io_eType_Agent
,
&
AgentInit
,
&
AgentClose
,
if
(
io_CheckClassIoType
(
io_eType_Agent
,
class
))
&
AgentRead
,
&
AgentWrite
);
if
(
ODD
(
sts
)
&&
(
AgentInit
!=
NULL
||
AgentClose
!=
NULL
||
AgentRead
!=
NULL
||
AgentWrite
!=
NULL
))
return
IO__TRV_NEXT
;
return
IO__TRV_NEXT
;
}
}
sts
=
io_FindMethods
(
class
,
io_eType_Rack
,
&
RackInit
,
&
RackClose
,
&
RackRead
,
&
RackWrite
);
if
(
io_CheckClassIoType
(
io_eType_Rack
,
class
))
{
if
(
ODD
(
sts
))
sts
=
io_FindMethods
(
class
,
io_eType_Rack
,
&
RackInit
,
&
RackClose
,
&
RackRead
,
&
RackWrite
);
{
if
(
ODD
(
sts
))
{
if
(
RackInit
!=
NULL
||
RackClose
!=
NULL
||
RackRead
!=
NULL
||
RackWrite
!=
NULL
)
if
(
RackInit
!=
NULL
||
RackClose
!=
NULL
||
RackRead
!=
NULL
||
RackWrite
!=
NULL
)
{
{
/* This is a rack object, */
/* This is a rack object, */
/* Check if the rack should be handled by this process */
/* Check if the rack should be handled by this process */
sts
=
gdh_ObjidToName
(
objid
,
rname
,
sizeof
(
rname
),
sts
=
gdh_ObjidToName
(
objid
,
rname
,
sizeof
(
rname
),
cdh_mName_volumeStrict
);
cdh_mName_volumeStrict
);
if
(
EVEN
(
sts
))
return
sts
;
if
(
EVEN
(
sts
))
return
sts
;
ok
=
0
;
ok
=
0
;
strcpy
(
attrname
,
rname
);
strcpy
(
attrname
,
rname
);
strcat
(
attrname
,
".Process"
);
strcat
(
attrname
,
".Process"
);
sts
=
gdh_GetObjectInfo
(
attrname
,
&
process
,
sizeof
(
process
));
sts
=
gdh_GetObjectInfo
(
attrname
,
&
process
,
sizeof
(
process
));
if
(
EVEN
(
sts
)
||
if
(
EVEN
(
sts
)
||
(
ODD
(
sts
)
&&
ctx
->
Process
&
process
))
(
ODD
(
sts
)
&&
ctx
->
Process
&
process
))
{
{
if
(
EVEN
(
sts
))
if
(
EVEN
(
sts
))
process
=
io_mProcess_All
;
process
=
io_mProcess_All
;
if
(
process
&
io_mProcess_Plc
)
{
if
(
process
&
io_mProcess_Plc
)
/* Check thread also */
{
strcpy
(
attrname
,
rname
);
/* Check thread also */
strcat
(
attrname
,
".ThreadObject"
);
strcpy
(
attrname
,
rname
);
sts
=
gdh_GetObjectInfo
(
attrname
,
&
thread
,
sizeof
(
thread
));
strcat
(
attrname
,
".ThreadObject"
);
if
(
EVEN
(
sts
))
sts
=
gdh_GetObjectInfo
(
attrname
,
&
thread
,
sizeof
(
thread
));
ok
=
1
;
if
(
EVEN
(
sts
))
else
if
(
ODD
(
sts
)
&&
cdh_ObjidIsEqual
(
thread
,
ctx
->
Thread
))
ok
=
1
;
ok
=
1
;
else
if
(
ODD
(
sts
)
&&
cdh_ObjidIsEqual
(
thread
,
ctx
->
Thread
))
}
else
ok
=
1
;
ok
=
1
;
}
}
else
ok
=
1
;
}
if
(
ok
)
if
(
ok
)
{
{
/* Treat this rack in this process */
/* Treat this rack in this process */
rp
=
calloc
(
1
,
sizeof
(
io_sRack
));
rp
=
calloc
(
1
,
sizeof
(
io_sRack
));
rp
->
Local
=
NULL
;
rp
->
Local
=
NULL
;
rp
->
Class
=
class
;
rp
->
Class
=
class
;
rp
->
Objid
=
objid
;
rp
->
Objid
=
objid
;
strcpy
(
rp
->
Name
,
rname
);
strcpy
(
rp
->
Name
,
rname
);
rp
->
Process
=
process
;
rp
->
Process
=
process
;
if
(
RackRead
!=
NULL
)
if
(
RackRead
!=
NULL
)
rp
->
Action
|=
io_mAction_Read
;
rp
->
Action
|=
io_mAction_Read
;
if
(
RackWrite
!=
NULL
)
if
(
RackWrite
!=
NULL
)
rp
->
Action
|=
io_mAction_Write
;
rp
->
Action
|=
io_mAction_Write
;
rp
->
Init
=
RackInit
;
rp
->
Init
=
RackInit
;
rp
->
Close
=
RackClose
;
rp
->
Close
=
RackClose
;
rp
->
Read
=
RackRead
;
rp
->
Read
=
RackRead
;
rp
->
Write
=
RackWrite
;
rp
->
Write
=
RackWrite
;
if
(
agent_type
==
io_eType_Agent
)
if
(
agent_type
==
io_eType_Agent
)
rp
->
AgentControlled
=
1
;
rp
->
AgentControlled
=
1
;
memset
(
&
attrref
,
0
,
sizeof
(
attrref
));
memset
(
&
attrref
,
0
,
sizeof
(
attrref
));
attrref
.
Objid
=
objid
;
attrref
.
Objid
=
objid
;
sts
=
gdh_DLRefObjectInfoAttrref
(
&
attrref
,
&
rp
->
op
,
&
rp
->
Dlid
);
sts
=
gdh_DLRefObjectInfoAttrref
(
&
attrref
,
&
rp
->
op
,
&
rp
->
Dlid
);
if
(
EVEN
(
sts
))
return
sts
;
if
(
EVEN
(
sts
))
return
sts
;
strcpy
(
attrname
,
rname
);
strcpy
(
attrname
,
rname
);
strcat
(
attrname
,
".ScanTime"
);
strcat
(
attrname
,
".ScanTime"
);
sts
=
gdh_GetObjectInfo
(
attrname
,
&
scantime
,
sizeof
(
scantime
));
sts
=
gdh_GetObjectInfo
(
attrname
,
&
scantime
,
sizeof
(
scantime
));
if
(
ODD
(
sts
))
if
(
ODD
(
sts
))
rp
->
scan_interval
=
scantime
/
ctx
->
ScanTime
+
FLT_EPSILON
;
rp
->
scan_interval
=
scantime
/
ctx
->
ScanTime
+
FLT_EPSILON
;
else
else
rp
->
scan_interval
=
1
;
rp
->
scan_interval
=
1
;
/* Insert last in racklist */
/* Insert last in racklist */
if
(
ap
->
racklist
==
NULL
)
if
(
ap
->
racklist
==
NULL
)
ap
->
racklist
=
rp
;
ap
->
racklist
=
rp
;
else
else
{
{
for
(
rlp
=
ap
->
racklist
;
rlp
->
next
!=
NULL
;
rlp
=
rlp
->
next
)
;
for
(
rlp
=
ap
->
racklist
;
rlp
->
next
!=
NULL
;
rlp
=
rlp
->
next
)
;
rlp
->
next
=
rp
;
rlp
->
next
=
rp
;
}
sts
=
io_trv_child
(
objid
,
0
,
io_init_card
,
ctx
,
rp
,
agent_type
);
}
}
return
IO__TRV_NEXT
;
sts
=
io_trv_child
(
objid
,
0
,
io_init_card
,
ctx
,
rp
,
agent_type
);
}
}
return
IO__TRV_NEXT
;
}
}
}
}
return
IO__SUCCESS
;
return
IO__SUCCESS
;
...
@@ -1754,84 +1722,80 @@ static pwr_tStatus io_init_agent(
...
@@ -1754,84 +1722,80 @@ static pwr_tStatus io_init_agent(
sts
=
gdh_GetObjectClass
(
objid
,
&
class
);
sts
=
gdh_GetObjectClass
(
objid
,
&
class
);
if
(
EVEN
(
sts
))
return
sts
;
if
(
EVEN
(
sts
))
return
sts
;
sts
=
io_FindMethods
(
class
,
io_eType_Agent
,
&
AgentInit
,
&
AgentClose
,
&
AgentRead
,
&
AgentWrite
);
if
(
io_CheckClassIoType
(
io_eType_Agent
,
class
))
{
if
(
ODD
(
sts
))
sts
=
io_FindMethods
(
class
,
io_eType_Agent
,
&
AgentInit
,
&
AgentClose
,
&
AgentRead
,
&
AgentWrite
);
{
if
(
ODD
(
sts
))
{
if
(
AgentInit
!=
NULL
||
AgentClose
!=
NULL
||
AgentRead
!=
NULL
||
AgentWrite
!=
NULL
)
if
(
AgentInit
!=
NULL
||
AgentClose
!=
NULL
||
AgentRead
!=
NULL
||
AgentWrite
!=
NULL
)
{
{
/* This is a agent object or the node object, */
/* This is a agent object or the node object, */
/* Check if the agent should be handled by this process */
/* Check if the agent should be handled by this process */
sts
=
gdh_ObjidToName
(
objid
,
aname
,
sizeof
(
aname
),
sts
=
gdh_ObjidToName
(
objid
,
aname
,
sizeof
(
aname
),
cdh_mName_volumeStrict
);
cdh_mName_volumeStrict
);
if
(
EVEN
(
sts
))
return
sts
;
if
(
EVEN
(
sts
))
return
sts
;
ok
=
0
;
ok
=
0
;
strcpy
(
attrname
,
aname
);
strcpy
(
attrname
,
aname
);
strcat
(
attrname
,
".Process"
);
strcat
(
attrname
,
".Process"
);
sts
=
gdh_GetObjectInfo
(
attrname
,
&
process
,
sizeof
(
process
));
sts
=
gdh_GetObjectInfo
(
attrname
,
&
process
,
sizeof
(
process
));
if
(
EVEN
(
sts
)
||
if
(
EVEN
(
sts
)
||
(
ODD
(
sts
)
&&
ctx
->
Process
&
process
))
(
ODD
(
sts
)
&&
ctx
->
Process
&
process
))
{
{
if
(
EVEN
(
sts
))
if
(
EVEN
(
sts
))
process
=
io_mProcess_All
;
process
=
io_mProcess_All
;
if
(
ctx
->
Process
==
io_mProcess_Profibus
)
if
(
ctx
->
Process
==
io_mProcess_Profibus
)
ok
=
1
;
ok
=
1
;
else
if
(
process
&
io_mProcess_Plc
)
{
else
if
(
process
&
io_mProcess_Plc
)
/* Check thread also */
{
strcpy
(
attrname
,
aname
);
/* Check thread also */
strcat
(
attrname
,
".ThreadObject"
);
strcpy
(
attrname
,
aname
);
sts
=
gdh_GetObjectInfo
(
attrname
,
&
thread
,
sizeof
(
thread
));
strcat
(
attrname
,
".ThreadObject"
);
if
(
EVEN
(
sts
))
sts
=
gdh_GetObjectInfo
(
attrname
,
&
thread
,
sizeof
(
thread
));
ok
=
1
;
if
(
EVEN
(
sts
))
else
if
(
ODD
(
sts
)
&&
cdh_ObjidIsEqual
(
thread
,
ctx
->
Thread
))
ok
=
1
;
ok
=
1
;
else
if
(
ODD
(
sts
)
&&
cdh_ObjidIsEqual
(
thread
,
ctx
->
Thread
))
}
else
ok
=
1
;
ok
=
1
;
}
}
else
ok
=
1
;
}
if
(
ok
)
{
/* Treat this agent in this process */
if
(
ok
)
{
ap
=
calloc
(
1
,
sizeof
(
io_sAgent
));
ap
->
Class
=
class
;
/* Treat this agent in this process */
ap
->
Local
=
NULL
;
ap
=
calloc
(
1
,
sizeof
(
io_sAgent
));
ap
->
Objid
=
objid
;
ap
->
Class
=
class
;
strcpy
(
ap
->
Name
,
aname
);
ap
->
Local
=
NULL
;
ap
->
Process
=
process
;
ap
->
Objid
=
objid
;
if
(
AgentRead
!=
NULL
)
strcpy
(
ap
->
Name
,
aname
);
ap
->
Action
|=
io_mAction_Read
;
ap
->
Process
=
process
;
if
(
AgentWrite
!=
NULL
)
if
(
AgentRead
!=
NULL
)
ap
->
Action
|=
io_mAction_Write
;
ap
->
Action
|=
io_mAction_Read
;
ap
->
Init
=
AgentInit
;
if
(
AgentWrite
!=
NULL
)
ap
->
Close
=
AgentClose
;
ap
->
Action
|=
io_mAction_Write
;
ap
->
Read
=
AgentRead
;
ap
->
Init
=
AgentInit
;
ap
->
Write
=
AgentWrite
;
ap
->
Close
=
AgentClose
;
memset
(
&
attrref
,
0
,
sizeof
(
attrref
));
ap
->
Read
=
AgentRead
;
attrref
.
Objid
=
objid
;
ap
->
Write
=
AgentWrite
;
sts
=
gdh_DLRefObjectInfoAttrref
(
&
attrref
,
&
ap
->
op
,
&
ap
->
Dlid
);
memset
(
&
attrref
,
0
,
sizeof
(
attrref
));
if
(
EVEN
(
sts
))
return
sts
;
attrref
.
Objid
=
objid
;
strcpy
(
attrname
,
aname
);
sts
=
gdh_DLRefObjectInfoAttrref
(
&
attrref
,
&
ap
->
op
,
&
ap
->
Dlid
);
strcat
(
attrname
,
".ScanTime"
);
if
(
EVEN
(
sts
))
return
sts
;
sts
=
gdh_GetObjectInfo
(
attrname
,
&
scantime
,
sizeof
(
scantime
));
strcpy
(
attrname
,
aname
);
if
(
ODD
(
sts
))
strcat
(
attrname
,
".ScanTime"
);
ap
->
scan_interval
=
scantime
/
ctx
->
ScanTime
+
FLT_EPSILON
;
sts
=
gdh_GetObjectInfo
(
attrname
,
&
scantime
,
sizeof
(
scantime
));
else
if
(
ODD
(
sts
))
ap
->
scan_interval
=
1
;
ap
->
scan_interval
=
scantime
/
ctx
->
ScanTime
+
FLT_EPSILON
;
else
ap
->
scan_interval
=
1
;
/* Insert last in agentlist */
/* Insert last in agentlist */
if
(
ctx
->
agentlist
==
NULL
)
if
(
ctx
->
agentlist
==
NULL
)
ctx
->
agentlist
=
ap
;
ctx
->
agentlist
=
ap
;
else
else
{
{
for
(
alp
=
ctx
->
agentlist
;
alp
->
next
!=
NULL
;
alp
=
alp
->
next
)
;
for
(
alp
=
ctx
->
agentlist
;
alp
->
next
!=
NULL
;
alp
=
alp
->
next
)
;
alp
->
next
=
ap
;
alp
->
next
=
ap
;
}
sts
=
io_trv_child
(
objid
,
0
,
io_init_rack
,
ctx
,
ap
,
agent_type
);
}
}
sts
=
io_trv_child
(
objid
,
0
,
io_init_rack
,
ctx
,
ap
,
agent_type
);
}
}
}
}
}
}
...
...
src/lib/rt/src/rt_io_base.h
View file @
7b057e27
...
@@ -258,4 +258,9 @@ pwr_tStatus io_GetIoTypeClasses(
...
@@ -258,4 +258,9 @@ pwr_tStatus io_GetIoTypeClasses(
pwr_tClassId
**
classes
,
pwr_tClassId
**
classes
,
int
*
size
int
*
size
);
);
int
io_CheckClassIoType
(
io_eType
type
,
pwr_tCid
cid
);
#endif
#endif
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