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
a27529a3
Commit
a27529a3
authored
Mar 22, 2004
by
claes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Subscription of arrays
parent
2d8ffd26
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
755 additions
and
447 deletions
+755
-447
java/exe/jpwr_rt_gdh/src/jpwr_rt_gdh.c
java/exe/jpwr_rt_gdh/src/jpwr_rt_gdh.c
+121
-7
java/exe/jpwr_rt_gdh/src/jpwr_rt_gdh.h
java/exe/jpwr_rt_gdh/src/jpwr_rt_gdh.h
+32
-0
java/jpwr/jop/src/GeDynTable.java
java/jpwr/jop/src/GeDynTable.java
+28
-20
java/jpwr/rt/src/Gdh.java
java/jpwr/rt/src/Gdh.java
+8
-1
java/jpwr/rt/src/GdhServer.java
java/jpwr/rt/src/GdhServer.java
+132
-80
java/jpwr/rt/src/GdhrRefObjectInfo.java
java/jpwr/rt/src/GdhrRefObjectInfo.java
+17
-0
java/jpwr/rt/src/Sub.java
java/jpwr/rt/src/Sub.java
+13
-24
java/jpwr/rt/src/SubElement.java
java/jpwr/rt/src/SubElement.java
+4
-1
java/jpwr/rt_client/src/Gdh.java
java/jpwr/rt_client/src/Gdh.java
+99
-94
src/jpwr/jop/src/GeDynTable.java
src/jpwr/jop/src/GeDynTable.java
+28
-20
src/jpwr/rt/src/Gdh.java
src/jpwr/rt/src/Gdh.java
+8
-1
src/jpwr/rt/src/GdhServer.java
src/jpwr/rt/src/GdhServer.java
+132
-80
src/jpwr/rt/src/GdhrRefObjectInfo.java
src/jpwr/rt/src/GdhrRefObjectInfo.java
+17
-0
src/jpwr/rt/src/Sub.java
src/jpwr/rt/src/Sub.java
+13
-24
src/jpwr/rt/src/SubElement.java
src/jpwr/rt/src/SubElement.java
+4
-1
src/jpwr/rt_client/src/Gdh.java
src/jpwr/rt_client/src/Gdh.java
+99
-94
No files found.
java/exe/jpwr_rt_gdh/src/jpwr_rt_gdh.c
View file @
a27529a3
...
...
@@ -250,6 +250,120 @@ JNIEXPORT jstring JNICALL Java_jpwr_rt_Gdh_getObjectRefInfoString
}
}
JNIEXPORT
jfloatArray
JNICALL
Java_jpwr_rt_Gdh_getObjectRefInfoFloatArray
(
JNIEnv
*
env
,
jclass
obj
,
jint
id
,
jint
size
)
{
jfloatArray
jfloatArr
=
(
*
env
)
->
NewFloatArray
(
env
,
size
);
if
(
jfloatArr
==
NULL
||
((
float
*
)
id
==
NULL
)
)
{
//something very weird has happen
return
(
jfloatArray
)
NULL
;
}
(
*
env
)
->
SetFloatArrayRegion
(
env
,
jfloatArr
,
0
,
size
,
(
jfloat
*
)
id
);
return
jfloatArr
;
}
JNIEXPORT
jbooleanArray
JNICALL
Java_jpwr_rt_Gdh_getObjectRefInfoBooleanArray
(
JNIEnv
*
env
,
jclass
obj
,
jint
id
,
jint
size
)
{
jbooleanArray
jbooleanArr
=
(
*
env
)
->
NewBooleanArray
(
env
,
size
);
if
(
jbooleanArr
==
NULL
||
((
pwr_tBoolean
*
)
id
==
NULL
)
)
{
//something very weird has happen
return
(
jbooleanArray
)
NULL
;
}
(
*
env
)
->
SetBooleanArrayRegion
(
env
,
jbooleanArr
,
0
,
size
,
(
jboolean
*
)
id
);
return
jbooleanArr
;
}
JNIEXPORT
jintArray
JNICALL
Java_jpwr_rt_Gdh_getObjectRefInfoIntArray
(
JNIEnv
*
env
,
jclass
obj
,
jint
id
,
jint
size
)
{
jintArray
jintArr
=
(
*
env
)
->
NewIntArray
(
env
,
size
);
if
(
jintArr
==
NULL
||
((
pwr_tInt32
*
)
id
==
NULL
)
)
{
//something very weird has happen
return
(
jintArray
)
NULL
;
}
(
*
env
)
->
SetIntArrayRegion
(
env
,
jintArr
,
0
,
size
,
(
jint
*
)
id
);
return
jintArr
;
}
JNIEXPORT
jobjectArray
JNICALL
Java_jpwr_rt_Gdh_getObjectRefInfoStringArray
(
JNIEnv
*
env
,
jclass
obj
,
jint
id
,
jint
jtypeid
,
jint
size
,
jint
elements
)
{
pwr_tTypeId
typeid
;
jobjectArray
jobjectArr
;
int
i
=
0
;
//find the class for String[]
jclass
strArrCls
=
(
*
env
)
->
FindClass
(
env
,
"java/lang/String"
);
if
(
strArrCls
==
NULL
)
{
return
(
jobjectArray
)
NULL
;
}
//create a new String[]
jobjectArr
=
(
*
env
)
->
NewObjectArray
(
env
,
elements
,
strArrCls
,
NULL
);
printf
(
"size=%d
\n
"
,
size
);
typeid
=
(
pwr_tTypeId
)
jtypeid
;
if
(
typeid
==
0
||
typeid
==
pwr_eType_String
)
{
// String is default
//put the result in an objectarray of Strings
for
(
i
=
0
;
i
<
elements
;
i
++
)
{
(
*
env
)
->
SetObjectArrayElement
(
env
,
jobjectArr
,
i
,
(
*
env
)
->
NewStringUTF
(
env
,
(
char
*
)
id
));
id
+=
size
;
}
}
else
{
char
buffer
[
256
];
int
len
;
/*
switch( typeid) {
case pwr_eType_Objid:
size = sizeof(pwr_tObjid);
break;
case pwr_eType_AttrRef:
size = sizeof(pwr_tAttrRef);
break;
case pwr_eType_Time:
size = sizeof(pwr_tTime);
break;
case pwr_eType_DeltaTime:
size = sizeof(pwr_tDeltaTime);
break;
default:
size = 4;
}
*/
//put the result in an objectarray of Strings
for
(
i
=
0
;
i
<
elements
;
i
++
)
{
gdh_AttrToString
(
typeid
,
(
void
*
)
id
,
buffer
,
sizeof
(
buffer
),
&
len
,
NULL
);
(
*
env
)
->
SetObjectArrayElement
(
env
,
jobjectArr
,
i
,
(
*
env
)
->
NewStringUTF
(
env
,
(
char
*
)
buffer
));
id
+=
size
;
}
}
return
jobjectArr
;
}
JNIEXPORT
jobject
JNICALL
Java_jpwr_rt_Gdh_refObjectInfo
(
JNIEnv
*
env
,
jclass
obj
,
jstring
name
)
...
...
@@ -282,8 +396,8 @@ JNIEXPORT jobject JNICALL Java_jpwr_rt_Gdh_refObjectInfo
if
(
gdhrRefObjectInfo_cid
==
NULL
)
{
gdhrRefObjectInfo_cid
=
(
*
env
)
->
GetMethodID
(
env
,
gdhrRefObjectInfo_id
,
"<init>"
,
"(Ljpwr/rt/PwrtRefId;III)V"
);
//printf("gdhrRefObjectInfo_cid initierad\n");
"<init>"
,
"(Ljpwr/rt/PwrtRefId;III
II
)V"
);
if
(
gdhrRefObjectInfo_cid
==
NULL
)
{
printf
(
"fel vid init av gdhrRefObjectInfo_cid
\n
"
);
...
...
@@ -315,6 +429,7 @@ JNIEXPORT jobject JNICALL Java_jpwr_rt_Gdh_refObjectInfo
{
typeid
=
pwr_eType_Boolean
;
size
=
sizeof
(
pwr_tBoolean
);
elements
=
1
;
}
sts
=
gdh_RefObjectInfo
(
cstr
,
&
attr_p
,
&
subid
,
size
);
...
...
@@ -332,8 +447,11 @@ JNIEXPORT jobject JNICALL Java_jpwr_rt_Gdh_refObjectInfo
id
=
0
;
jsts
=
(
jint
)
sts
;
//we want the size of each element not the hole object
if
(
elements
>
0
)
size
=
size
/
elements
;
return_obj
=
(
*
env
)
->
NewObject
(
env
,
gdhrRefObjectInfo_id
,
gdhrRefObjectInfo_cid
,
refid_obj
,
id
,
jsts
,
(
jint
)
typeid
);
gdhrRefObjectInfo_cid
,
refid_obj
,
id
,
jsts
,
(
jint
)
typeid
,
(
jint
)
elements
,
(
jint
)
size
);
return
return_obj
;
}
...
...
@@ -472,7 +590,6 @@ JNIEXPORT jobject JNICALL Java_jpwr_rt_Gdh_objidToName
{
cdhrString_cid
=
(
*
env
)
->
GetMethodID
(
env
,
cdhrString_id
,
"<init>"
,
"(Ljava/lang/String;I)V"
);
//printf("cdhrString_cid initierad\n");
}
PwrtObjid_id
=
(
*
env
)
->
FindClass
(
env
,
"jpwr/rt/PwrtObjid"
);
...
...
@@ -480,7 +597,6 @@ JNIEXPORT jobject JNICALL Java_jpwr_rt_Gdh_objidToName
{
PwrtObjid_getOix
=
(
*
env
)
->
GetMethodID
(
env
,
PwrtObjid_id
,
"getOix"
,
"()I"
);
PwrtObjid_getVid
=
(
*
env
)
->
GetMethodID
(
env
,
PwrtObjid_id
,
"getVid"
,
"()I"
);
//printf("PwrtObjid_xxx initierad\n");
}
objid
.
oix
=
(
*
env
)
->
CallIntMethod
(
env
,
objid_obj
,
PwrtObjid_getOix
);
...
...
@@ -556,7 +672,6 @@ JNIEXPORT jobject JNICALL Java_jpwr_rt_Gdh_getChild
{
cdhrObjid_cid
=
(
*
env
)
->
GetMethodID
(
env
,
cdhrObjid_id
,
"<init>"
,
"(Ljpwr/rt/PwrtObjid;I)V"
);
//printf("cdhrObjid initierad\n");
}
PwrtObjid_id
=
(
*
env
)
->
FindClass
(
env
,
"jpwr/rt/PwrtObjid"
);
...
...
@@ -567,7 +682,6 @@ JNIEXPORT jobject JNICALL Java_jpwr_rt_Gdh_getChild
"<init>"
,
"(II)V"
);
PwrtObjid_getOix
=
(
*
env
)
->
GetMethodID
(
env
,
PwrtObjid_id
,
"getOix"
,
"()I"
);
PwrtObjid_getVid
=
(
*
env
)
->
GetMethodID
(
env
,
PwrtObjid_id
,
"getVid"
,
"()I"
);
//printf("PwrtObjid_xxx initierade\n");
}
objid
.
oix
=
(
*
env
)
->
CallIntMethod
(
env
,
objid_obj
,
PwrtObjid_getOix
);
...
...
java/exe/jpwr_rt_gdh/src/jpwr_rt_gdh.h
View file @
a27529a3
...
...
@@ -140,6 +140,38 @@ JNIEXPORT jint JNICALL Java_jpwr_rt_Gdh_getObjectRefInfoInt
JNIEXPORT
jstring
JNICALL
Java_jpwr_rt_Gdh_getObjectRefInfoString
(
JNIEnv
*
,
jobject
,
jint
,
jint
);
/*
* Class: jpwr_rt_Gdh
* Method: getObjectRefInfoFloatArray
* Signature: (II)[F
*/
JNIEXPORT
jfloatArray
JNICALL
Java_jpwr_rt_Gdh_getObjectRefInfoFloatArray
(
JNIEnv
*
,
jobject
,
jint
,
jint
);
/*
* Class: jpwr_rt_Gdh
* Method: getObjectRefInfoBooleanArray
* Signature: (II)[Z
*/
JNIEXPORT
jbooleanArray
JNICALL
Java_jpwr_rt_Gdh_getObjectRefInfoBooleanArray
(
JNIEnv
*
,
jobject
,
jint
,
jint
);
/*
* Class: jpwr_rt_Gdh
* Method: getObjectRefInfoIntArray
* Signature: (II)[I
*/
JNIEXPORT
jintArray
JNICALL
Java_jpwr_rt_Gdh_getObjectRefInfoIntArray
(
JNIEnv
*
,
jobject
,
jint
,
jint
);
/*
* Class: jpwr_rt_Gdh
* Method: getObjectRefInfoStringArray
* Signature: (IIII)[Ljava/lang/String;
*/
JNIEXPORT
jobjectArray
JNICALL
Java_jpwr_rt_Gdh_getObjectRefInfoStringArray
(
JNIEnv
*
,
jobject
,
jint
,
jint
,
jint
,
jint
);
/*
* Class: jpwr_rt_Gdh
* Method: unrefObjectInfo
...
...
java/jpwr/jop/src/GeDynTable.java
View file @
a27529a3
...
...
@@ -14,6 +14,8 @@ public class GeDynTable extends GeDynElem {
public
boolean
[]
selAttrFound
;
PwrtRefId
[]
subid
;
int
[]
p
;
public
int
[]
elements
;
public
int
[]
size
;
public
int
[]
typeId
;
public
boolean
[][]
oldValueB
;
public
float
[][]
oldValueF
;
...
...
@@ -35,6 +37,8 @@ public class GeDynTable extends GeDynElem {
p
=
new
int
[
columns
];
subid
=
new
PwrtRefId
[
columns
];
typeId
=
new
int
[
columns
];
elements
=
new
int
[
columns
];
size
=
new
int
[
columns
];
attrFound
=
new
boolean
[
columns
];
selAttrFound
=
new
boolean
[
columns
];
oldValueB
=
new
boolean
[
columns
][];
...
...
@@ -57,6 +61,10 @@ public class GeDynTable extends GeDynElem {
p
[
i
]
=
ret
.
id
;
subid
[
i
]
=
ret
.
refid
;
typeId
[
i
]
=
ret
.
typeId
;
elements
[
i
]
=
ret
.
getElements
();
size
[
i
]
=
ret
.
getSize
();
if
(
elements
[
i
]
>
rows
)
elements
[
i
]
=
rows
;
if
(
typeId
[
i
]
==
Pwr
.
eType_Float32
)
{
oldValueF
[
i
]
=
new
float
[
rows
];
}
...
...
@@ -92,26 +100,26 @@ public class GeDynTable extends GeDynElem {
continue
;
if
(
typeId
[
i
]
==
Pwr
.
eType_Float32
)
{
float
value0
=
dyn
.
en
.
gdh
.
getObjectRefInfoFloat
(
p
[
i
]);
for
(
int
j
=
0
;
j
<
1
;
j
++)
{
// Just the first row...
if
(
value0
!=
oldValueF
[
i
][
j
]
||
firstScan
)
{
sb
=
cFormat
[
i
].
format
(
value0
,
sb
);
float
[]
value0
=
dyn
.
en
.
gdh
.
getObjectRefInfoFloatArray
(
p
[
i
],
elements
[
i
]);
for
(
int
j
=
0
;
j
<
value0
.
length
;
j
++)
{
if
(
value0
[
j
]
!=
oldValueF
[
i
][
j
]
||
firstScan
)
{
sb
=
cFormat
[
i
].
format
(
value0
[
j
]
,
sb
);
((
GeTable
)
dyn
.
comp
).
setValueAt
(
new
String
(
sb
),
j
,
i
);
// dyn.repaintNow = true;
oldValueF
[
i
][
j
]
=
value0
;
oldValueF
[
i
][
j
]
=
value0
[
j
]
;
}
}
}
else
if
(
typeId
[
i
]
==
Pwr
.
eType_Boolean
)
{
boolean
value0
=
dyn
.
en
.
gdh
.
getObjectRefInfoBoolean
(
p
[
i
]);
for
(
int
j
=
0
;
j
<
1
;
j
++)
{
// Just the first row...
if
(
value0
!=
oldValueB
[
i
][
j
]
||
firstScan
)
{
if
(
value0
)
boolean
[]
value0
=
dyn
.
en
.
gdh
.
getObjectRefInfoBooleanArray
(
p
[
i
],
elements
[
i
]);
for
(
int
j
=
0
;
j
<
value0
.
length
;
j
++)
{
if
(
value0
[
j
]
!=
oldValueB
[
i
][
j
]
||
firstScan
)
{
if
(
value0
[
j
]
)
((
GeTable
)
dyn
.
comp
).
setValueAt
(
"1"
,
j
,
i
);
else
((
GeTable
)
dyn
.
comp
).
setValueAt
(
"0"
,
j
,
i
);
// dyn.repaintNow = true;
oldValueB
[
i
][
j
]
=
value0
;
oldValueB
[
i
][
j
]
=
value0
[
j
]
;
}
}
}
...
...
@@ -121,26 +129,26 @@ public class GeDynTable extends GeDynElem {
typeId
[
i
]
==
Pwr
.
eType_UInt16
||
typeId
[
i
]
==
Pwr
.
eType_Int8
||
typeId
[
i
]
==
Pwr
.
eType_UInt8
)
{
int
value0
=
dyn
.
en
.
gdh
.
getObjectRefInfoInt
(
p
[
i
]);
for
(
int
j
=
0
;
j
<
1
;
j
++)
{
// Just the first row...
if
(
value0
!=
oldValueI
[
i
][
j
]
||
firstScan
)
{
sb
=
cFormat
[
i
].
format
(
value0
,
sb
);
int
value0
[]
=
dyn
.
en
.
gdh
.
getObjectRefInfoIntArray
(
p
[
i
],
elements
[
i
]);
for
(
int
j
=
0
;
j
<
value0
.
length
;
j
++)
{
if
(
value0
[
j
]
!=
oldValueI
[
i
][
j
]
||
firstScan
)
{
sb
=
cFormat
[
i
].
format
(
value0
[
j
]
,
sb
);
((
GeTable
)
dyn
.
comp
).
setValueAt
(
new
String
(
sb
),
j
,
i
);
// dyn.repaintNow = true;
oldValueI
[
i
][
j
]
=
value0
;
oldValueI
[
i
][
j
]
=
value0
[
j
]
;
}
}
}
else
if
(
typeId
[
i
]
==
Pwr
.
eType_String
||
typeId
[
i
]
==
Pwr
.
eType_Objid
)
{
String
value0
=
dyn
.
en
.
gdh
.
getObjectRefInfoString
(
p
[
i
],
typeId
[
i
]);
for
(
int
j
=
0
;
j
<
1
;
j
++)
{
// Just the first row...
if
(
firstScan
||
value0
.
compareTo
(
oldValueS
[
i
][
j
])
!=
0
)
{
sb
=
cFormat
[
i
].
format
(
value0
,
sb
);
String
[]
value0
=
dyn
.
en
.
gdh
.
getObjectRefInfoStringArray
(
p
[
i
],
typeId
[
i
],
size
[
i
],
elements
[
i
]);
for
(
int
j
=
0
;
j
<
value0
.
length
;
j
++)
{
if
(
firstScan
||
value0
[
j
]
.
compareTo
(
oldValueS
[
i
][
j
])
!=
0
)
{
sb
=
cFormat
[
i
].
format
(
value0
[
j
]
,
sb
);
((
GeTable
)
dyn
.
comp
).
setValueAt
(
new
String
(
sb
),
j
,
i
);
// dyn.repaintNow = true;
oldValueS
[
i
][
j
]
=
value0
;
oldValueS
[
i
][
j
]
=
value0
[
j
]
;
}
}
}
...
...
java/jpwr/rt/src/Gdh.java
View file @
a27529a3
...
...
@@ -252,7 +252,7 @@ public class Gdh {
return
retVec
;
}
public
Vector
unrefObjectInfo_Vector
(
Vector
vec
)
{
{
Vector
retVec
=
new
Vector
();
// for(int i = 0;i < vec.size();i++)
// {
...
...
@@ -274,10 +274,17 @@ public class Gdh {
public
native
CdhrObjid
getObjectInfoObjid
(
String
attributeName
);
public
native
PwrtStatus
toggleObjectInfo
(
String
attributeName
);
public
native
GdhrRefObjectInfo
refObjectInfo
(
String
attributeName
);
public
native
float
getObjectRefInfoFloat
(
int
id
);
public
native
boolean
getObjectRefInfoBoolean
(
int
id
);
public
native
int
getObjectRefInfoInt
(
int
id
);
public
native
String
getObjectRefInfoString
(
int
id
,
int
typeid
);
public
native
float
[]
getObjectRefInfoFloatArray
(
int
id
,
int
elements
);
public
native
boolean
[]
getObjectRefInfoBooleanArray
(
int
id
,
int
elements
);
public
native
int
[]
getObjectRefInfoIntArray
(
int
id
,
int
elements
);
public
native
String
[]
getObjectRefInfoStringArray
(
int
id
,
int
typeid
,
int
size
,
int
elements
);
public
native
PwrtStatus
unrefObjectInfo
(
PwrtRefId
refid
);
public
native
CdhrObjid
nameToObjid
(
String
objectName
);
public
native
CdhrString
objidToName
(
PwrtObjid
objid
,
int
nameType
);
...
...
java/jpwr/rt/src/GdhServer.java
View file @
a27529a3
...
...
@@ -62,13 +62,19 @@ public class GdhServer
public
final
static
int
CRR_OBJECT
=
43
;
public
final
static
int
GET_PARENT
=
44
;
public
final
static
int
GET_OBJECT_INFO_OBJID
=
45
;
public
final
static
int
GET_OBJECT_REF_INFO_BOOLEAN_ARRAY
=
46
;
public
final
static
int
GET_OBJECT_REF_INFO_FLOAT_ARRAY
=
47
;
public
final
static
int
GET_OBJECT_REF_INFO_INT_ARRAY
=
48
;
public
final
static
int
GET_OBJECT_REF_INFO_STRING_ARRAY
=
49
;
public
final
static
int
PORT
=
4445
;
public
final
static
int
__IO_EXCEPTION
=
2000
;
public
final
static
int
__UNREFED
=
0
;
static
ArrayList
subscriptions
=
new
ArrayList
();
// static Vector nrOfSubscriptionClients = new Vector();
static
int
subscriptionCount
=
0
;
static
int
threadCount
=
0
;
...
...
@@ -277,14 +283,14 @@ public class GdhServer
*/
public
GdhThread
(
Socket
clientSocket
,
int
threadNumber
,
int
maxConnections
)
{
/*
/*
*********** In case of debugging this might be useful
System.out.println("threadnumber : " + threadNumber + "maxconn " + maxConnections);
try{
System.out.println("HostName :" + clientSocket.getInetAddress().getHostName() +
"Delay : " + clientSocket.getTcpNoDelay());
}
catch(SocketException exc){}
*/
*
************************************
/
this
.
threadNumber
=
threadNumber
;
this
.
clientSocket
=
clientSocket
;
this
.
maxConnections
=
maxConnections
;
...
...
@@ -315,9 +321,6 @@ public class GdhServer
out
.
flush
();
in
=
new
ObjectInputStream
(
new
BufferedInputStream
(
clientSocket
.
getInputStream
()));
//buff = new BufferedOutputStream(clientSocket.getOutputStream());
//outbuff = new ObjectOutputStream(buff);
}
catch
(
IOException
e
)
{
...
...
@@ -330,7 +333,6 @@ public class GdhServer
try
{
// out.writeLong(9998);
int
function
=
in
.
readInt
();
while
(
function
!=
9999
)
{
...
...
@@ -516,6 +518,8 @@ public class GdhServer
out
.
writeInt
(
ret
.
refid
.
nid
);
out
.
writeInt
(
thSub
.
size
()
-
1
);
out
.
writeInt
(
ret
.
typeId
);
out
.
writeInt
(
ret
.
size
);
out
.
writeInt
(
ret
.
elements
);
}
out
.
flush
();
}
...
...
@@ -544,7 +548,8 @@ public class GdhServer
out
.
writeInt
(
ret
.
refid
.
nid
);
out
.
writeInt
(
thSub
.
size
()
-
1
);
out
.
writeInt
(
ret
.
typeId
);
out
.
writeInt
(
ret
.
size
);
out
.
writeInt
(
ret
.
elements
);
}
}
out
.
flush
();
...
...
@@ -559,8 +564,6 @@ public class GdhServer
case
REF_OBJECT_INFO_VECTOR:
try
{
//System.out.println("Start p refobjinfvec" + (new Timestamp(new Date().getTime())).toString());
//Vector retVec = new Vector();
Vector
vec
=
(
Vector
)
in
.
readObject
();
if
(
vec
==
null
)
{
...
...
@@ -569,7 +572,6 @@ public class GdhServer
out
.
flush
();
break
;
}
//Sub gdhRet;
String
attrName
;
Vector
gdhRet
=
new
Vector
(
vec
.
size
());
for
(
int
j
=
0
;
j
<
vec
.
size
();
j
++)
...
...
@@ -583,7 +585,9 @@ public class GdhServer
new
PwrtRefId
(
thSub
.
size
()
-
1
,
ret
.
refid
.
nid
),
ret
.
id
,
ret
.
typeId
,
ret
.
subscriptionsIndex
);
ret
.
subscriptionsIndex
,
ret
.
elements
,
ret
.
size
);
retToCli
.
sts
=
ret
.
sts
;
gdhRet
.
add
(
retToCli
);
}
...
...
@@ -596,8 +600,6 @@ public class GdhServer
out
.
writeObject
(
gdhRet
);
out
.
flush
();
//out.reset();
//System.out.println("Stop p refobjinfvec " + (new Timestamp(new Date().getTime())).toString());
}
catch
(
NotSerializableException
e
)
{
...
...
@@ -621,38 +623,17 @@ public class GdhServer
System
.
out
.
println
(
"Start GET_OBJECT_REF_INFO_ALL"
+
(
new
Timestamp
(
new
Date
().
getTime
())).
toString
());
}
Sub
subElement
;
//Object cli[] = new Object[thSub.size()];
for
(
i
=
0
;
i
<
thSub
.
size
();
i
++)
{
subElement
=
((
Sub
)
thSub
.
elementAt
(
i
));
int
index
=
subElement
.
getIndex
();
//int id = (int)((SubElement)subCopy.elementAt(index)).sub.id;
//int typeId = (int)((SubElement)subCopy.elementAt(index)).sub.typeId;
int
id
=
subElement
.
id
;
int
typeId
=
subElement
.
typeId
;
/* if(sub.sts == __UNREFED)
{
continue;
}
boolean found = false;
for(int j = 0; j < ((SubElement)subCopy.elementAt(i)).reffedByThread.length; j++)
{
if(((SubElement)subCopy.elementAt(i)).reffedByThread[j][0] == threadNumber)
{
found = true;
break;
}
}
if(!found)
{
continue;
}
*/
//System.out.println(id + " typeId " + typeId);
//System.out.println("refinfoall");
int
elements
=
subElement
.
elements
;
int
size
=
subElement
.
size
;
switch
(
typeId
)
{
case
Pwr
.
eType_Int32
:
...
...
@@ -661,49 +642,49 @@ public class GdhServer
case
Pwr
.
eType_UInt16
:
case
Pwr
.
eType_Int8
:
case
Pwr
.
eType_UInt8
:
//cli[i] = new Integer(gdh.getObjectRefInfoInt(id));
out
.
writeInt
(
gdh
.
getObjectRefInfoInt
(
id
));
if
(
elements
>
1
)
{
//its an array
out
.
writeObject
(
gdh
.
getObjectRefInfoIntArray
(
id
,
elements
));
}
else
out
.
writeInt
(
gdh
.
getObjectRefInfoInt
(
id
));
break
;
case
Pwr
.
eType_Float32
:
//cli[i] = new Float(gdh.getObjectRefInfoFloat(id));
out
.
writeFloat
(
gdh
.
getObjectRefInfoFloat
(
id
));
if
(
elements
>
1
)
{
//its an array
out
.
writeObject
(
gdh
.
getObjectRefInfoFloatArray
(
id
,
elements
));
}
else
out
.
writeFloat
(
gdh
.
getObjectRefInfoFloat
(
id
));
break
;
case
0
:
case
Pwr
.
eType_Boolean
:
//cli[i] = new Boolean(gdh.getObjectRefInfoBoolean(id));
out
.
writeBoolean
(
gdh
.
getObjectRefInfoBoolean
(
id
));
if
(
elements
>
1
)
{
//its an array
out
.
writeObject
(
gdh
.
getObjectRefInfoBooleanArray
(
id
,
elements
));
}
else
out
.
writeBoolean
(
gdh
.
getObjectRefInfoBoolean
(
id
));
break
;
default
:
//cli[i] = gdh.getObjectRefInfoString(id, typeId);
out
.
writeObject
(
gdh
.
getObjectRefInfoString
(
id
,
typeId
));
if
(
elements
>
1
)
{
//its an array
out
.
writeObject
(
gdh
.
getObjectRefInfoStringArray
(
id
,
typeId
,
size
,
elements
));
}
else
out
.
writeObject
(
gdh
.
getObjectRefInfoString
(
id
,
typeId
));
break
;
}
//index = null;
//id = null;
//typeId = null;
}
try
{
//out.writeObject(cli);
out
.
flush
();
/*
long K = 1024;
long freeMem = Runtime.getRuntime().freeMemory() / K;
long totalMem = Runtime.getRuntime().totalMemory() / K;
System.out.println("Storlek p thSub: " + thSub.size() +
"storlek p sub: " + subscriptions.size() +
"Tillgngligt minne: " + freeMem + " KB" +
"Totalt minne: " + totalMem + " KB");
//ej behvligt
subCopy = null;
cli = null;
subElement = null;
*/
//mste gras annars tar minnet slut...
//must be done if we dont want memory leaks...
out
.
reset
();
//System.gc();
//System.runFinalization();
if
(
logRefInfoAll
)
{
System
.
out
.
println
(
"Slut GET_OBJECT_REF_INFO_ALL"
+
(
new
Timestamp
(
new
Date
().
getTime
())).
toString
());
...
...
@@ -724,7 +705,6 @@ public class GdhServer
{
System
.
out
.
println
(
"getObjectRefInfoAll: IO exception"
);
}
//System.out.println("efter GET_OBJECT_REF_INFO_ALL");
break
;
case
GET_OBJECT_REF_INFO_FLOAT:
try
...
...
@@ -779,6 +759,84 @@ public class GdhServer
System
.
out
.
println
(
"getObjectRefInfoString: IO exception"
);
}
break
;
case
GET_OBJECT_REF_INFO_FLOAT_ARRAY:
try
{
int
id
=
in
.
readInt
();
int
index
=
((
Sub
)
thSub
.
elementAt
(
id
)).
getIndex
();
int
elements
=
((
Sub
)
thSub
.
elementAt
(
id
)).
getElements
();
out
.
writeObject
(
gdh
.
getObjectRefInfoFloatArray
(
index
,
elements
));
out
.
flush
();
}
catch
(
IOException
e
)
{
System
.
out
.
println
(
"getObjectRefInfoFloatArray: IO exception"
);
}
break
;
case
GET_OBJECT_REF_INFO_BOOLEAN_ARRAY:
try
{
int
id
=
in
.
readInt
();
int
index
=
((
Sub
)
thSub
.
elementAt
(
id
)).
getIndex
();
int
elements
=
((
Sub
)
thSub
.
elementAt
(
id
)).
getElements
();
out
.
writeObject
(
gdh
.
getObjectRefInfoBooleanArray
(
index
,
elements
));
out
.
flush
();
}
catch
(
IOException
e
)
{
System
.
out
.
println
(
"getObjectRefInfoBooleanArray: IO exception"
);
}
break
;
case
GET_OBJECT_REF_INFO_INT_ARRAY:
try
{
int
id
=
in
.
readInt
();
int
index
=
((
Sub
)
thSub
.
elementAt
(
id
)).
getIndex
();
int
elements
=
((
Sub
)
thSub
.
elementAt
(
id
)).
getElements
();
out
.
writeObject
(
gdh
.
getObjectRefInfoIntArray
(
index
,
elements
));
out
.
flush
();
}
catch
(
IOException
e
)
{
System
.
out
.
println
(
"getObjectRefInfoIntArray: IO exception"
);
}
break
;
case
GET_OBJECT_REF_INFO_STRING_ARRAY:
try
{
int
id
=
in
.
readInt
();
int
typeid
=
in
.
readInt
();
int
index
=
((
Sub
)
thSub
.
elementAt
(
id
)).
getIndex
();
int
elements
=
((
Sub
)
thSub
.
elementAt
(
id
)).
getElements
();
int
size
=
((
Sub
)
thSub
.
elementAt
(
id
)).
getSize
();
out
.
writeObject
(
gdh
.
getObjectRefInfoStringArray
(
index
,
typeid
,
size
,
elements
));
out
.
flush
();
}
catch
(
IOException
e
)
{
System
.
out
.
println
(
"getObjectRefInfoStringArray: IO exception"
);
}
break
;
case
UNREF_OBJECT_INFO:
try
{
...
...
@@ -1425,10 +1483,9 @@ public class GdhServer
ThreadNumbersConnected
[
ii
]
+=
j
+
", "
;
NumberOfPrenumerations
[
ii
]
+=
subEl
.
reffedByThread
[
j
]
+
", "
;
}
//ObjectAttributeNames[ii] = ((SubElement)subcp.get(ii)).sub.attrName;
}
}
//Object obj[][] = {ObjectAttributeNames, ThreadNumbersConnected, NumberOfPrenumerations};
out
.
writeInt
(
subcp
.
size
());
out
.
writeInt
(
nrOfSub
);
...
...
@@ -1441,11 +1498,9 @@ public class GdhServer
out
.
writeLong
(
Runtime
.
getRuntime
().
totalMemory
());
out
.
flush
();
//m
ste gras annars tar minnet slut
...
//m
ust be done if we dont want memory leaks
...
out
.
reset
();
//System.gc();
}
catch
(
OutOfMemoryError
e
)
{
...
...
@@ -1492,17 +1547,17 @@ public class GdhServer
{
System
.
err
.
println
(
"Close failed"
);
}
//
loopa igenom och kontrollera att alla prenumerationer har stoppats
//
check that all subscriptions has stopped
for
(
i
=
0
;
i
<
thSub
.
size
();
i
++)
{
try
{
sub
=
((
Sub
)
thSub
.
elementAt
(
i
));
int
index
=
((
Sub
)
thSub
.
elementAt
(
i
)).
getIndex
();
//PwrtRefId refid = (PwrtRefId)((SubElement)subCopy.elementAt(index)).sub.refid;
PwrtStatus
sts
=
this
.
unrefObjectInfo
(
new
PwrtRefId
(
index
,
sub
.
refid
.
nid
),
threadNumber
);
// System.out.println("unrefall :" + index + refid.nid);
}
catch
(
ArrayIndexOutOfBoundsException
exc
)
{
...
...
@@ -1529,7 +1584,7 @@ public class GdhServer
*@param threadNumber Description of the Parameter
*@return Description of the Return Value
*/
public
synchronized
Sub
refObjectInfo
(
String
attrName
,
int
threadNumber
/*, boolean putNextSubAtSubVecEnd*/
)
public
synchronized
Sub
refObjectInfo
(
String
attrName
,
int
threadNumber
)
{
SubElement
sub
;
int
firstUnreffedIndex
=
subscriptionCount
;
...
...
@@ -1562,8 +1617,6 @@ public class GdhServer
if
(
ret
.
oddSts
())
{
sub
=
new
SubElement
(
maxConnections
,
threadNumber
);
//sub.refObjectInfo = ret;
//sub.attrName = attrName;
if
(
notFoundUnreffed
)
{
//System.out.println("this.refObjectInfo ej reffad ej lucka i subsc.. " + attrName + " " + subscriptionCount);
...
...
@@ -1582,7 +1635,6 @@ public class GdhServer
subscriptions
.
add
(
firstUnreffedIndex
,
sub
);
sub
.
reffedByThreadBitSet
.
set
(
threadNumber
);
sub
.
reffedByThread
[
threadNumber
]++;
//lastIndexReffed = firstUnreffedIndex;
}
}
else
...
...
java/jpwr/rt/src/GdhrRefObjectInfo.java
View file @
a27529a3
...
...
@@ -16,14 +16,31 @@ public class GdhrRefObjectInfo implements Serializable
public
int
sts
;
public
int
typeId
;
public
int
subId
;
public
int
elements
;
public
int
size
;
public
GdhrRefObjectInfo
(
PwrtRefId
refid
,
int
id
,
int
sts
,
int
typeId
)
{
this
.
refid
=
refid
;
this
.
id
=
id
;
this
.
sts
=
sts
;
this
.
typeId
=
typeId
;
//default values in case we have forgotten to use the new constructor
this
.
elements
=
1
;
this
.
size
=
4
;
}
public
GdhrRefObjectInfo
(
PwrtRefId
refid
,
int
id
,
int
sts
,
int
typeId
,
int
elements
,
int
size
)
{
this
.
refid
=
refid
;
this
.
id
=
id
;
this
.
sts
=
sts
;
this
.
typeId
=
typeId
;
this
.
elements
=
elements
;
this
.
size
=
size
;
}
public
boolean
evenSts
()
{
return
(
sts
%
2
==
0
);}
public
boolean
oddSts
()
{
return
(
sts
%
2
==
1
);}
public
int
getSts
()
{
return
sts
;}
public
int
getElements
(){
return
elements
;}
public
int
getSize
(){
return
size
;}
}
java/jpwr/rt/src/Sub.java
View file @
a27529a3
...
...
@@ -14,22 +14,16 @@
public
float
valueFloat
;
public
boolean
valueBoolean
;
public
String
valueString
;
/*
public PwrtRefId refid;
public int id;
public int sts;
public int typeId;
public int subId;
*/
public
int
[]
valueIntArray
;
public
float
[]
valueFloatArray
;
public
boolean
[]
valueBooleanArray
;
public
String
[]
valueStringArray
;
public
Sub
(
String
attrName
,
PwrtRefId
refid
,
int
id
,
int
typeId
,
int
subscriptionsIndex
,
int
valueInt
,
float
valueFloat
,
boolean
valueBoolean
,
String
valueString
)
{
/*
this.refid = refid;
this.id = id;
this.sts = 0;
this.typeId = typeId;
*/
super
(
refid
,
id
,
0
,
typeId
);
this
.
subscriptionsIndex
=
subscriptionsIndex
;
this
.
valueInt
=
valueInt
;
...
...
@@ -69,25 +63,20 @@
public
Sub
(
String
attrName
,
PwrtRefId
refid
,
int
id
,
int
typeId
,
int
subscriptionsIndex
)
public
Sub
(
String
attrName
,
PwrtRefId
refid
,
int
id
,
int
typeId
,
int
subscriptionsIndex
,
int
elements
,
int
size
)
{
/*
this.refid = refid;
this.id = id;
this.sts = sts;
this.typeId = typeId;
*/
super
(
refid
,
id
,
0
,
typeId
);
super
(
refid
,
id
,
0
,
typeId
,
elements
,
size
);
this
.
attrName
=
attrName
;
this
.
subscriptionsIndex
=
subscriptionsIndex
;
}
//public boolean evenSts() { return (sts % 2 == 0);}
//public boolean oddSts() { return (sts % 2 == 1);}
//public int getSts() { return sts;}
int
getIndex
()
{
return
subscriptionsIndex
;
}
}
java/jpwr/rt/src/SubElement.java
View file @
a27529a3
...
...
@@ -11,7 +11,7 @@
{
public
int
[]
reffedByThread
;
public
BitSet
reffedByThreadBitSet
;
Sub
sub
=
new
Sub
(
" "
,
new
PwrtRefId
(
0
,
0
),
0
,
0
,
0
);
Sub
sub
=
new
Sub
(
" "
,
new
PwrtRefId
(
0
,
0
),
0
,
0
,
0
,
0
,
0
);
public
SubElement
(
int
maxConnections
,
int
threadNumber
)
...
...
@@ -40,6 +40,8 @@
this
.
sub
.
id
=
obj
.
id
;
this
.
sub
.
sts
=
obj
.
sts
;
this
.
sub
.
typeId
=
obj
.
typeId
;
this
.
sub
.
size
=
obj
.
size
;
this
.
sub
.
elements
=
obj
.
elements
;
this
.
sub
.
subscriptionsIndex
=
subscriptionsIndex
;
}
...
...
@@ -48,3 +50,4 @@
return
(
this
.
sub
.
attrName
.
equalsIgnoreCase
(((
SubElement
)
o
).
sub
.
attrName
)
&&
(((
SubElement
)
o
).
sub
.
sts
!=
0
));
}
}
java/jpwr/rt_client/src/Gdh.java
View file @
a27529a3
...
...
@@ -52,6 +52,13 @@ public class Gdh
public
final
static
int
GET_PARENT
=
44
;
public
final
static
int
GET_OBJECT_INFO_OBJID
=
45
;
public
final
static
int
GET_OBJECT_REF_INFO_BOOLEAN_ARRAY
=
46
;
public
final
static
int
GET_OBJECT_REF_INFO_FLOAT_ARRAY
=
47
;
public
final
static
int
GET_OBJECT_REF_INFO_INT_ARRAY
=
48
;
public
final
static
int
GET_OBJECT_REF_INFO_STRING_ARRAY
=
49
;
public
final
static
int
__IO_EXCEPTION
=
2000
;
public
final
static
int
__BUSY
=
2002
;
public
final
static
int
__UNREFED
=
0
;
...
...
@@ -367,7 +374,7 @@ public class Gdh
return
new
GdhrRefObjectInfo
(
null
,
0
,
0
,
0
);
}
//qqq
Sub
sub
=
new
Sub
(
attributeName
,
null
,
0
,
typeId
,
subscriptionCount
);
Sub
sub
=
new
Sub
(
attributeName
,
null
,
0
,
typeId
,
subscriptionCount
,
0
,
0
);
subscriptions
.
insertElementAt
(
sub
,
subscriptionCount
);
subscriptionCount
++;
return
new
GdhrRefObjectInfo
(
refid
,
id
,
1
,
typeId
);
...
...
@@ -395,13 +402,15 @@ public class Gdh
PwrtRefId
refid
=
new
PwrtRefId
(
rix
,
nid
);
int
id
=
in
.
readInt
();
int
typeId
=
in
.
readInt
();
Sub
sub
=
new
Sub
(
attributeName
,
refid
,
id
,
typeId
,
subscriptionCount
);
int
size
=
in
.
readInt
();
int
elements
=
in
.
readInt
();
Sub
sub
=
new
Sub
(
attributeName
,
refid
,
id
,
typeId
,
subscriptionCount
,
size
,
elements
);
sub
.
sts
=
1
;
subscriptions
.
insertElementAt
(
sub
,
id
);
subscriptionCount
++;
refid
=
new
PwrtRefId
(
id
,
0
);
subLate
++;
return
new
GdhrRefObjectInfo
(
refid
,
id
,
sts
,
typeId
);
return
new
GdhrRefObjectInfo
(
refid
,
id
,
sts
,
typeId
,
size
,
elements
);
}
catch
(
IOException
e
)
{
...
...
@@ -420,6 +429,7 @@ public class Gdh
int
nid
;
int
id
;
int
typeId
;
PwrtRefId
refid
;
if
(
listSent
)
...
...
@@ -472,6 +482,8 @@ public class Gdh
sub
.
refid
=
new
PwrtRefId
(
rix
,
nid
);
id
=
in
.
readInt
();
typeId
=
in
.
readInt
();
sub
.
size
=
in
.
readInt
();
sub
.
elements
=
in
.
readInt
();
}
locked
=
false
;
notify
();
...
...
@@ -540,8 +552,7 @@ public class Gdh
}
ret
.
id
=
ret
.
refid
.
rix
;
subscriptions
.
add
(
ret
);
//((Sub)retVec.get(i)).refid.rix = ((Sub)retVec.get(i)).id;
//System.out.println("Status " + ((Sub)retVec.get(i)).getSts());
}
subscriptionCount
+=
retVec
.
size
();
...
...
@@ -591,17 +602,24 @@ public class Gdh
//System.out.println("ArrayIndexOutOfBounds getObjectRefInfoFloat");
return
0
F
;
}
/*
try {
out.writeInt( GET_OBJECT_REF_INFO_FLOAT);
out.writeInt( id);
return in.readFloat();
} catch (IOException e) {
return 0F;
}
*/
}
public
float
[]
getObjectRefInfoFloatArray
(
int
id
,
int
elements
)
{
try
{
Sub
sub
=
(
Sub
)
subscriptions
.
elementAt
(
id
);
if
(
sub
.
oddSts
())
{
return
sub
.
valueFloatArray
;
}
return
null
;
}
catch
(
ArrayIndexOutOfBoundsException
e
)
{
//System.out.println("ArrayIndexOutOfBounds getObjectRefInfoFloat");
return
null
;
}
}
public
boolean
getObjectRefInfoBoolean
(
int
id
)
{
...
...
@@ -619,45 +637,61 @@ public class Gdh
//System.out.println("ArrayIndexOutOfBounds getObjectRefInfoBoolean");
return
false
;
}
/*
try {
out.writeInt( GET_OBJECT_REF_INFO_BOOLEAN);
out.writeInt( id);
return in.readBoolean();
} catch (IOException e) {
return false;
}
*/
}
public
int
getObjectRefInfoInt
(
int
id
)
public
boolean
[]
getObjectRefInfoBooleanArray
(
int
id
,
int
elements
)
{
try
{
Sub
sub
=
(
Sub
)
subscriptions
.
elementAt
(
id
);
if
(
sub
.
oddSts
())
Sub
sub
=
(
Sub
)
subscriptions
.
elementAt
(
id
);
if
(
sub
.
oddSts
())
{
return
sub
.
valueBooleanArray
;
}
return
null
;
}
catch
(
ArrayIndexOutOfBoundsException
e
)
{
return
sub
.
valueInt
;
//System.out.println("ArrayIndexOutOfBounds getObjectRefInfoBoolean");
return
null
;
}
return
0
;
}
public
int
getObjectRefInfoInt
(
int
id
)
{
try
{
Sub
sub
=
(
Sub
)
subscriptions
.
elementAt
(
id
);
if
(
sub
.
oddSts
())
{
return
sub
.
valueInt
;
}
return
0
;
}
catch
(
ArrayIndexOutOfBoundsException
e
)
catch
(
ArrayIndexOutOfBoundsException
e
)
{
//System.out.println("ArrayIndexOutOfBounds getObjectRefInfoInt");
return
0
;
}
/*
try {
out.writeInt( GET_OBJECT_REF_INFO_INT);
out.writeInt( id);
return in.readInt();
} catch (IOException e) {
return 0;
}
*/
}
public
int
[]
getObjectRefInfoIntArray
(
int
id
,
int
elements
)
{
try
{
Sub
sub
=
(
Sub
)
subscriptions
.
elementAt
(
id
);
if
(
sub
.
oddSts
())
{
return
sub
.
valueIntArray
;
}
return
null
;
}
catch
(
ArrayIndexOutOfBoundsException
e
)
{
//System.out.println("ArrayIndexOutOfBounds getObjectRefInfoInt");
return
null
;
}
}
public
String
getObjectRefInfoString
(
int
id
,
int
typeid
)
{
...
...
@@ -677,19 +711,31 @@ public class Gdh
//System.out.println("ArrayIndexOutOfBounds getObjectRefInfoString index " + id);
return
" "
;
}
/*
try {
out.writeInt( GET_OBJECT_REF_INFO_STRING);
out.writeInt( id);
out.writeInt( typeid);
return in.readUTF();
} catch (IOException e) {
return "";
}
public
String
[]
getObjectRefInfoStringArray
(
int
id
,
int
typeid
,
int
size
,
int
elements
)
{
try
{
Sub
sub
=
(
Sub
)
subscriptions
.
elementAt
(
id
);
if
(
sub
.
evenSts
()
||
sub
.
valueStringArray
==
null
)
{
if
(
sub
.
evenSts
())
System
.
out
.
println
(
"getObjectRefInfoString substs "
+
sub
.
getSts
()
+
" id "
+
id
);
return
null
;
}
return
sub
.
valueStringArray
;
}
catch
(
ArrayIndexOutOfBoundsException
e
)
{
//System.out.println("ArrayIndexOutOfBounds getObjectRefInfoString index " + id);
return
null
;
}
*/
}
public
synchronized
PwrtStatus
unrefObjectInfo
(
PwrtRefId
refid
)
{
try
...
...
@@ -1231,36 +1277,8 @@ public class Gdh
out
.
writeInt
(
GET_OBJECT_REF_INFO_ALL
);
out
.
flush
();
//Object retArray[] = (Object[])in.readObject();
//Object retArray[] = (Object[])inbuff.readObject();
//Object ret[] = (Object[])retArray[0];
//String sVec[] = (String[])retArray[0];
//boolean bVec[] = (boolean[])retArray[1];
//int iVec[] = (int[])retArray[2];
//float fVec[] = (float[])retArray[3];
/*
int thSubSize = in.readInt();
Object ret[] = (Object[])in.readObject();
*/
//subscriptions.clear();
//subscriptions.setSize(ret.length);
/*
String sVec[] = (String[])in.readObject();
boolean bVec[] = (boolean[])in.readObject();
int iVec[] = (int[])in.readObject();
float fVec[] = (float[])in.readObject();
*/
for
(
int
i
=
0
;
i
<
subscriptions
.
size
();
i
++)
{
//subscriptions.set(i, (jpwr.rt.Sub)ret[i]);
/*
((jpwr.rt.Sub)(subscriptions.get(i))).valueString = sVec[i];
((jpwr.rt.Sub)(subscriptions.get(i))).valueBoolean = bVec[i];
((jpwr.rt.Sub)(subscriptions.get(i))).valueInt = iVec[i];
((jpwr.rt.Sub)(subscriptions.get(i))).valueFloat = fVec[i];
*/
try
{
...
...
@@ -1645,24 +1663,11 @@ public class Gdh
return
0
;
}
/*
private class Sub extends GdhrRefObjectInfo implements Serializable
{
String attrName;
int subscriptionsIndex;
int valueInt;
float valueFloat;
boolean valueBoolean;
String valueString;
}
public Sub(String attrName, PwrtRefId refid, int id, int typeId, int subscriptionsIndex)
{
super(refid, id, 0, typeId);
this.attrName = attrName;
this.subscriptionsIndex = subscriptionsIndex;
}
}
*/
}
src/jpwr/jop/src/GeDynTable.java
View file @
a27529a3
...
...
@@ -14,6 +14,8 @@ public class GeDynTable extends GeDynElem {
public
boolean
[]
selAttrFound
;
PwrtRefId
[]
subid
;
int
[]
p
;
public
int
[]
elements
;
public
int
[]
size
;
public
int
[]
typeId
;
public
boolean
[][]
oldValueB
;
public
float
[][]
oldValueF
;
...
...
@@ -35,6 +37,8 @@ public class GeDynTable extends GeDynElem {
p
=
new
int
[
columns
];
subid
=
new
PwrtRefId
[
columns
];
typeId
=
new
int
[
columns
];
elements
=
new
int
[
columns
];
size
=
new
int
[
columns
];
attrFound
=
new
boolean
[
columns
];
selAttrFound
=
new
boolean
[
columns
];
oldValueB
=
new
boolean
[
columns
][];
...
...
@@ -57,6 +61,10 @@ public class GeDynTable extends GeDynElem {
p
[
i
]
=
ret
.
id
;
subid
[
i
]
=
ret
.
refid
;
typeId
[
i
]
=
ret
.
typeId
;
elements
[
i
]
=
ret
.
getElements
();
size
[
i
]
=
ret
.
getSize
();
if
(
elements
[
i
]
>
rows
)
elements
[
i
]
=
rows
;
if
(
typeId
[
i
]
==
Pwr
.
eType_Float32
)
{
oldValueF
[
i
]
=
new
float
[
rows
];
}
...
...
@@ -92,26 +100,26 @@ public class GeDynTable extends GeDynElem {
continue
;
if
(
typeId
[
i
]
==
Pwr
.
eType_Float32
)
{
float
value0
=
dyn
.
en
.
gdh
.
getObjectRefInfoFloat
(
p
[
i
]);
for
(
int
j
=
0
;
j
<
1
;
j
++)
{
// Just the first row...
if
(
value0
!=
oldValueF
[
i
][
j
]
||
firstScan
)
{
sb
=
cFormat
[
i
].
format
(
value0
,
sb
);
float
[]
value0
=
dyn
.
en
.
gdh
.
getObjectRefInfoFloatArray
(
p
[
i
],
elements
[
i
]);
for
(
int
j
=
0
;
j
<
value0
.
length
;
j
++)
{
if
(
value0
[
j
]
!=
oldValueF
[
i
][
j
]
||
firstScan
)
{
sb
=
cFormat
[
i
].
format
(
value0
[
j
]
,
sb
);
((
GeTable
)
dyn
.
comp
).
setValueAt
(
new
String
(
sb
),
j
,
i
);
// dyn.repaintNow = true;
oldValueF
[
i
][
j
]
=
value0
;
oldValueF
[
i
][
j
]
=
value0
[
j
]
;
}
}
}
else
if
(
typeId
[
i
]
==
Pwr
.
eType_Boolean
)
{
boolean
value0
=
dyn
.
en
.
gdh
.
getObjectRefInfoBoolean
(
p
[
i
]);
for
(
int
j
=
0
;
j
<
1
;
j
++)
{
// Just the first row...
if
(
value0
!=
oldValueB
[
i
][
j
]
||
firstScan
)
{
if
(
value0
)
boolean
[]
value0
=
dyn
.
en
.
gdh
.
getObjectRefInfoBooleanArray
(
p
[
i
],
elements
[
i
]);
for
(
int
j
=
0
;
j
<
value0
.
length
;
j
++)
{
if
(
value0
[
j
]
!=
oldValueB
[
i
][
j
]
||
firstScan
)
{
if
(
value0
[
j
]
)
((
GeTable
)
dyn
.
comp
).
setValueAt
(
"1"
,
j
,
i
);
else
((
GeTable
)
dyn
.
comp
).
setValueAt
(
"0"
,
j
,
i
);
// dyn.repaintNow = true;
oldValueB
[
i
][
j
]
=
value0
;
oldValueB
[
i
][
j
]
=
value0
[
j
]
;
}
}
}
...
...
@@ -121,26 +129,26 @@ public class GeDynTable extends GeDynElem {
typeId
[
i
]
==
Pwr
.
eType_UInt16
||
typeId
[
i
]
==
Pwr
.
eType_Int8
||
typeId
[
i
]
==
Pwr
.
eType_UInt8
)
{
int
value0
=
dyn
.
en
.
gdh
.
getObjectRefInfoInt
(
p
[
i
]);
for
(
int
j
=
0
;
j
<
1
;
j
++)
{
// Just the first row...
if
(
value0
!=
oldValueI
[
i
][
j
]
||
firstScan
)
{
sb
=
cFormat
[
i
].
format
(
value0
,
sb
);
int
value0
[]
=
dyn
.
en
.
gdh
.
getObjectRefInfoIntArray
(
p
[
i
],
elements
[
i
]);
for
(
int
j
=
0
;
j
<
value0
.
length
;
j
++)
{
if
(
value0
[
j
]
!=
oldValueI
[
i
][
j
]
||
firstScan
)
{
sb
=
cFormat
[
i
].
format
(
value0
[
j
]
,
sb
);
((
GeTable
)
dyn
.
comp
).
setValueAt
(
new
String
(
sb
),
j
,
i
);
// dyn.repaintNow = true;
oldValueI
[
i
][
j
]
=
value0
;
oldValueI
[
i
][
j
]
=
value0
[
j
]
;
}
}
}
else
if
(
typeId
[
i
]
==
Pwr
.
eType_String
||
typeId
[
i
]
==
Pwr
.
eType_Objid
)
{
String
value0
=
dyn
.
en
.
gdh
.
getObjectRefInfoString
(
p
[
i
],
typeId
[
i
]);
for
(
int
j
=
0
;
j
<
1
;
j
++)
{
// Just the first row...
if
(
firstScan
||
value0
.
compareTo
(
oldValueS
[
i
][
j
])
!=
0
)
{
sb
=
cFormat
[
i
].
format
(
value0
,
sb
);
String
[]
value0
=
dyn
.
en
.
gdh
.
getObjectRefInfoStringArray
(
p
[
i
],
typeId
[
i
],
size
[
i
],
elements
[
i
]);
for
(
int
j
=
0
;
j
<
value0
.
length
;
j
++)
{
if
(
firstScan
||
value0
[
j
]
.
compareTo
(
oldValueS
[
i
][
j
])
!=
0
)
{
sb
=
cFormat
[
i
].
format
(
value0
[
j
]
,
sb
);
((
GeTable
)
dyn
.
comp
).
setValueAt
(
new
String
(
sb
),
j
,
i
);
// dyn.repaintNow = true;
oldValueS
[
i
][
j
]
=
value0
;
oldValueS
[
i
][
j
]
=
value0
[
j
]
;
}
}
}
...
...
src/jpwr/rt/src/Gdh.java
View file @
a27529a3
...
...
@@ -252,7 +252,7 @@ public class Gdh {
return
retVec
;
}
public
Vector
unrefObjectInfo_Vector
(
Vector
vec
)
{
{
Vector
retVec
=
new
Vector
();
// for(int i = 0;i < vec.size();i++)
// {
...
...
@@ -274,10 +274,17 @@ public class Gdh {
public
native
CdhrObjid
getObjectInfoObjid
(
String
attributeName
);
public
native
PwrtStatus
toggleObjectInfo
(
String
attributeName
);
public
native
GdhrRefObjectInfo
refObjectInfo
(
String
attributeName
);
public
native
float
getObjectRefInfoFloat
(
int
id
);
public
native
boolean
getObjectRefInfoBoolean
(
int
id
);
public
native
int
getObjectRefInfoInt
(
int
id
);
public
native
String
getObjectRefInfoString
(
int
id
,
int
typeid
);
public
native
float
[]
getObjectRefInfoFloatArray
(
int
id
,
int
elements
);
public
native
boolean
[]
getObjectRefInfoBooleanArray
(
int
id
,
int
elements
);
public
native
int
[]
getObjectRefInfoIntArray
(
int
id
,
int
elements
);
public
native
String
[]
getObjectRefInfoStringArray
(
int
id
,
int
typeid
,
int
size
,
int
elements
);
public
native
PwrtStatus
unrefObjectInfo
(
PwrtRefId
refid
);
public
native
CdhrObjid
nameToObjid
(
String
objectName
);
public
native
CdhrString
objidToName
(
PwrtObjid
objid
,
int
nameType
);
...
...
src/jpwr/rt/src/GdhServer.java
View file @
a27529a3
...
...
@@ -62,13 +62,19 @@ public class GdhServer
public
final
static
int
CRR_OBJECT
=
43
;
public
final
static
int
GET_PARENT
=
44
;
public
final
static
int
GET_OBJECT_INFO_OBJID
=
45
;
public
final
static
int
GET_OBJECT_REF_INFO_BOOLEAN_ARRAY
=
46
;
public
final
static
int
GET_OBJECT_REF_INFO_FLOAT_ARRAY
=
47
;
public
final
static
int
GET_OBJECT_REF_INFO_INT_ARRAY
=
48
;
public
final
static
int
GET_OBJECT_REF_INFO_STRING_ARRAY
=
49
;
public
final
static
int
PORT
=
4445
;
public
final
static
int
__IO_EXCEPTION
=
2000
;
public
final
static
int
__UNREFED
=
0
;
static
ArrayList
subscriptions
=
new
ArrayList
();
// static Vector nrOfSubscriptionClients = new Vector();
static
int
subscriptionCount
=
0
;
static
int
threadCount
=
0
;
...
...
@@ -277,14 +283,14 @@ public class GdhServer
*/
public
GdhThread
(
Socket
clientSocket
,
int
threadNumber
,
int
maxConnections
)
{
/*
/*
*********** In case of debugging this might be useful
System.out.println("threadnumber : " + threadNumber + "maxconn " + maxConnections);
try{
System.out.println("HostName :" + clientSocket.getInetAddress().getHostName() +
"Delay : " + clientSocket.getTcpNoDelay());
}
catch(SocketException exc){}
*/
*
************************************
/
this
.
threadNumber
=
threadNumber
;
this
.
clientSocket
=
clientSocket
;
this
.
maxConnections
=
maxConnections
;
...
...
@@ -315,9 +321,6 @@ public class GdhServer
out
.
flush
();
in
=
new
ObjectInputStream
(
new
BufferedInputStream
(
clientSocket
.
getInputStream
()));
//buff = new BufferedOutputStream(clientSocket.getOutputStream());
//outbuff = new ObjectOutputStream(buff);
}
catch
(
IOException
e
)
{
...
...
@@ -330,7 +333,6 @@ public class GdhServer
try
{
// out.writeLong(9998);
int
function
=
in
.
readInt
();
while
(
function
!=
9999
)
{
...
...
@@ -516,6 +518,8 @@ public class GdhServer
out
.
writeInt
(
ret
.
refid
.
nid
);
out
.
writeInt
(
thSub
.
size
()
-
1
);
out
.
writeInt
(
ret
.
typeId
);
out
.
writeInt
(
ret
.
size
);
out
.
writeInt
(
ret
.
elements
);
}
out
.
flush
();
}
...
...
@@ -544,7 +548,8 @@ public class GdhServer
out
.
writeInt
(
ret
.
refid
.
nid
);
out
.
writeInt
(
thSub
.
size
()
-
1
);
out
.
writeInt
(
ret
.
typeId
);
out
.
writeInt
(
ret
.
size
);
out
.
writeInt
(
ret
.
elements
);
}
}
out
.
flush
();
...
...
@@ -559,8 +564,6 @@ public class GdhServer
case
REF_OBJECT_INFO_VECTOR:
try
{
//System.out.println("Start p refobjinfvec" + (new Timestamp(new Date().getTime())).toString());
//Vector retVec = new Vector();
Vector
vec
=
(
Vector
)
in
.
readObject
();
if
(
vec
==
null
)
{
...
...
@@ -569,7 +572,6 @@ public class GdhServer
out
.
flush
();
break
;
}
//Sub gdhRet;
String
attrName
;
Vector
gdhRet
=
new
Vector
(
vec
.
size
());
for
(
int
j
=
0
;
j
<
vec
.
size
();
j
++)
...
...
@@ -583,7 +585,9 @@ public class GdhServer
new
PwrtRefId
(
thSub
.
size
()
-
1
,
ret
.
refid
.
nid
),
ret
.
id
,
ret
.
typeId
,
ret
.
subscriptionsIndex
);
ret
.
subscriptionsIndex
,
ret
.
elements
,
ret
.
size
);
retToCli
.
sts
=
ret
.
sts
;
gdhRet
.
add
(
retToCli
);
}
...
...
@@ -596,8 +600,6 @@ public class GdhServer
out
.
writeObject
(
gdhRet
);
out
.
flush
();
//out.reset();
//System.out.println("Stop p refobjinfvec " + (new Timestamp(new Date().getTime())).toString());
}
catch
(
NotSerializableException
e
)
{
...
...
@@ -621,38 +623,17 @@ public class GdhServer
System
.
out
.
println
(
"Start GET_OBJECT_REF_INFO_ALL"
+
(
new
Timestamp
(
new
Date
().
getTime
())).
toString
());
}
Sub
subElement
;
//Object cli[] = new Object[thSub.size()];
for
(
i
=
0
;
i
<
thSub
.
size
();
i
++)
{
subElement
=
((
Sub
)
thSub
.
elementAt
(
i
));
int
index
=
subElement
.
getIndex
();
//int id = (int)((SubElement)subCopy.elementAt(index)).sub.id;
//int typeId = (int)((SubElement)subCopy.elementAt(index)).sub.typeId;
int
id
=
subElement
.
id
;
int
typeId
=
subElement
.
typeId
;
/* if(sub.sts == __UNREFED)
{
continue;
}
boolean found = false;
for(int j = 0; j < ((SubElement)subCopy.elementAt(i)).reffedByThread.length; j++)
{
if(((SubElement)subCopy.elementAt(i)).reffedByThread[j][0] == threadNumber)
{
found = true;
break;
}
}
if(!found)
{
continue;
}
*/
//System.out.println(id + " typeId " + typeId);
//System.out.println("refinfoall");
int
elements
=
subElement
.
elements
;
int
size
=
subElement
.
size
;
switch
(
typeId
)
{
case
Pwr
.
eType_Int32
:
...
...
@@ -661,49 +642,49 @@ public class GdhServer
case
Pwr
.
eType_UInt16
:
case
Pwr
.
eType_Int8
:
case
Pwr
.
eType_UInt8
:
//cli[i] = new Integer(gdh.getObjectRefInfoInt(id));
out
.
writeInt
(
gdh
.
getObjectRefInfoInt
(
id
));
if
(
elements
>
1
)
{
//its an array
out
.
writeObject
(
gdh
.
getObjectRefInfoIntArray
(
id
,
elements
));
}
else
out
.
writeInt
(
gdh
.
getObjectRefInfoInt
(
id
));
break
;
case
Pwr
.
eType_Float32
:
//cli[i] = new Float(gdh.getObjectRefInfoFloat(id));
out
.
writeFloat
(
gdh
.
getObjectRefInfoFloat
(
id
));
if
(
elements
>
1
)
{
//its an array
out
.
writeObject
(
gdh
.
getObjectRefInfoFloatArray
(
id
,
elements
));
}
else
out
.
writeFloat
(
gdh
.
getObjectRefInfoFloat
(
id
));
break
;
case
0
:
case
Pwr
.
eType_Boolean
:
//cli[i] = new Boolean(gdh.getObjectRefInfoBoolean(id));
out
.
writeBoolean
(
gdh
.
getObjectRefInfoBoolean
(
id
));
if
(
elements
>
1
)
{
//its an array
out
.
writeObject
(
gdh
.
getObjectRefInfoBooleanArray
(
id
,
elements
));
}
else
out
.
writeBoolean
(
gdh
.
getObjectRefInfoBoolean
(
id
));
break
;
default
:
//cli[i] = gdh.getObjectRefInfoString(id, typeId);
out
.
writeObject
(
gdh
.
getObjectRefInfoString
(
id
,
typeId
));
if
(
elements
>
1
)
{
//its an array
out
.
writeObject
(
gdh
.
getObjectRefInfoStringArray
(
id
,
typeId
,
size
,
elements
));
}
else
out
.
writeObject
(
gdh
.
getObjectRefInfoString
(
id
,
typeId
));
break
;
}
//index = null;
//id = null;
//typeId = null;
}
try
{
//out.writeObject(cli);
out
.
flush
();
/*
long K = 1024;
long freeMem = Runtime.getRuntime().freeMemory() / K;
long totalMem = Runtime.getRuntime().totalMemory() / K;
System.out.println("Storlek p thSub: " + thSub.size() +
"storlek p sub: " + subscriptions.size() +
"Tillgngligt minne: " + freeMem + " KB" +
"Totalt minne: " + totalMem + " KB");
//ej behvligt
subCopy = null;
cli = null;
subElement = null;
*/
//mste gras annars tar minnet slut...
//must be done if we dont want memory leaks...
out
.
reset
();
//System.gc();
//System.runFinalization();
if
(
logRefInfoAll
)
{
System
.
out
.
println
(
"Slut GET_OBJECT_REF_INFO_ALL"
+
(
new
Timestamp
(
new
Date
().
getTime
())).
toString
());
...
...
@@ -724,7 +705,6 @@ public class GdhServer
{
System
.
out
.
println
(
"getObjectRefInfoAll: IO exception"
);
}
//System.out.println("efter GET_OBJECT_REF_INFO_ALL");
break
;
case
GET_OBJECT_REF_INFO_FLOAT:
try
...
...
@@ -779,6 +759,84 @@ public class GdhServer
System
.
out
.
println
(
"getObjectRefInfoString: IO exception"
);
}
break
;
case
GET_OBJECT_REF_INFO_FLOAT_ARRAY:
try
{
int
id
=
in
.
readInt
();
int
index
=
((
Sub
)
thSub
.
elementAt
(
id
)).
getIndex
();
int
elements
=
((
Sub
)
thSub
.
elementAt
(
id
)).
getElements
();
out
.
writeObject
(
gdh
.
getObjectRefInfoFloatArray
(
index
,
elements
));
out
.
flush
();
}
catch
(
IOException
e
)
{
System
.
out
.
println
(
"getObjectRefInfoFloatArray: IO exception"
);
}
break
;
case
GET_OBJECT_REF_INFO_BOOLEAN_ARRAY:
try
{
int
id
=
in
.
readInt
();
int
index
=
((
Sub
)
thSub
.
elementAt
(
id
)).
getIndex
();
int
elements
=
((
Sub
)
thSub
.
elementAt
(
id
)).
getElements
();
out
.
writeObject
(
gdh
.
getObjectRefInfoBooleanArray
(
index
,
elements
));
out
.
flush
();
}
catch
(
IOException
e
)
{
System
.
out
.
println
(
"getObjectRefInfoBooleanArray: IO exception"
);
}
break
;
case
GET_OBJECT_REF_INFO_INT_ARRAY:
try
{
int
id
=
in
.
readInt
();
int
index
=
((
Sub
)
thSub
.
elementAt
(
id
)).
getIndex
();
int
elements
=
((
Sub
)
thSub
.
elementAt
(
id
)).
getElements
();
out
.
writeObject
(
gdh
.
getObjectRefInfoIntArray
(
index
,
elements
));
out
.
flush
();
}
catch
(
IOException
e
)
{
System
.
out
.
println
(
"getObjectRefInfoIntArray: IO exception"
);
}
break
;
case
GET_OBJECT_REF_INFO_STRING_ARRAY:
try
{
int
id
=
in
.
readInt
();
int
typeid
=
in
.
readInt
();
int
index
=
((
Sub
)
thSub
.
elementAt
(
id
)).
getIndex
();
int
elements
=
((
Sub
)
thSub
.
elementAt
(
id
)).
getElements
();
int
size
=
((
Sub
)
thSub
.
elementAt
(
id
)).
getSize
();
out
.
writeObject
(
gdh
.
getObjectRefInfoStringArray
(
index
,
typeid
,
size
,
elements
));
out
.
flush
();
}
catch
(
IOException
e
)
{
System
.
out
.
println
(
"getObjectRefInfoStringArray: IO exception"
);
}
break
;
case
UNREF_OBJECT_INFO:
try
{
...
...
@@ -1425,10 +1483,9 @@ public class GdhServer
ThreadNumbersConnected
[
ii
]
+=
j
+
", "
;
NumberOfPrenumerations
[
ii
]
+=
subEl
.
reffedByThread
[
j
]
+
", "
;
}
//ObjectAttributeNames[ii] = ((SubElement)subcp.get(ii)).sub.attrName;
}
}
//Object obj[][] = {ObjectAttributeNames, ThreadNumbersConnected, NumberOfPrenumerations};
out
.
writeInt
(
subcp
.
size
());
out
.
writeInt
(
nrOfSub
);
...
...
@@ -1441,11 +1498,9 @@ public class GdhServer
out
.
writeLong
(
Runtime
.
getRuntime
().
totalMemory
());
out
.
flush
();
//m
ste gras annars tar minnet slut
...
//m
ust be done if we dont want memory leaks
...
out
.
reset
();
//System.gc();
}
catch
(
OutOfMemoryError
e
)
{
...
...
@@ -1492,17 +1547,17 @@ public class GdhServer
{
System
.
err
.
println
(
"Close failed"
);
}
//
loopa igenom och kontrollera att alla prenumerationer har stoppats
//
check that all subscriptions has stopped
for
(
i
=
0
;
i
<
thSub
.
size
();
i
++)
{
try
{
sub
=
((
Sub
)
thSub
.
elementAt
(
i
));
int
index
=
((
Sub
)
thSub
.
elementAt
(
i
)).
getIndex
();
//PwrtRefId refid = (PwrtRefId)((SubElement)subCopy.elementAt(index)).sub.refid;
PwrtStatus
sts
=
this
.
unrefObjectInfo
(
new
PwrtRefId
(
index
,
sub
.
refid
.
nid
),
threadNumber
);
// System.out.println("unrefall :" + index + refid.nid);
}
catch
(
ArrayIndexOutOfBoundsException
exc
)
{
...
...
@@ -1529,7 +1584,7 @@ public class GdhServer
*@param threadNumber Description of the Parameter
*@return Description of the Return Value
*/
public
synchronized
Sub
refObjectInfo
(
String
attrName
,
int
threadNumber
/*, boolean putNextSubAtSubVecEnd*/
)
public
synchronized
Sub
refObjectInfo
(
String
attrName
,
int
threadNumber
)
{
SubElement
sub
;
int
firstUnreffedIndex
=
subscriptionCount
;
...
...
@@ -1562,8 +1617,6 @@ public class GdhServer
if
(
ret
.
oddSts
())
{
sub
=
new
SubElement
(
maxConnections
,
threadNumber
);
//sub.refObjectInfo = ret;
//sub.attrName = attrName;
if
(
notFoundUnreffed
)
{
//System.out.println("this.refObjectInfo ej reffad ej lucka i subsc.. " + attrName + " " + subscriptionCount);
...
...
@@ -1582,7 +1635,6 @@ public class GdhServer
subscriptions
.
add
(
firstUnreffedIndex
,
sub
);
sub
.
reffedByThreadBitSet
.
set
(
threadNumber
);
sub
.
reffedByThread
[
threadNumber
]++;
//lastIndexReffed = firstUnreffedIndex;
}
}
else
...
...
src/jpwr/rt/src/GdhrRefObjectInfo.java
View file @
a27529a3
...
...
@@ -16,14 +16,31 @@ public class GdhrRefObjectInfo implements Serializable
public
int
sts
;
public
int
typeId
;
public
int
subId
;
public
int
elements
;
public
int
size
;
public
GdhrRefObjectInfo
(
PwrtRefId
refid
,
int
id
,
int
sts
,
int
typeId
)
{
this
.
refid
=
refid
;
this
.
id
=
id
;
this
.
sts
=
sts
;
this
.
typeId
=
typeId
;
//default values in case we have forgotten to use the new constructor
this
.
elements
=
1
;
this
.
size
=
4
;
}
public
GdhrRefObjectInfo
(
PwrtRefId
refid
,
int
id
,
int
sts
,
int
typeId
,
int
elements
,
int
size
)
{
this
.
refid
=
refid
;
this
.
id
=
id
;
this
.
sts
=
sts
;
this
.
typeId
=
typeId
;
this
.
elements
=
elements
;
this
.
size
=
size
;
}
public
boolean
evenSts
()
{
return
(
sts
%
2
==
0
);}
public
boolean
oddSts
()
{
return
(
sts
%
2
==
1
);}
public
int
getSts
()
{
return
sts
;}
public
int
getElements
(){
return
elements
;}
public
int
getSize
(){
return
size
;}
}
src/jpwr/rt/src/Sub.java
View file @
a27529a3
...
...
@@ -14,22 +14,16 @@
public
float
valueFloat
;
public
boolean
valueBoolean
;
public
String
valueString
;
/*
public PwrtRefId refid;
public int id;
public int sts;
public int typeId;
public int subId;
*/
public
int
[]
valueIntArray
;
public
float
[]
valueFloatArray
;
public
boolean
[]
valueBooleanArray
;
public
String
[]
valueStringArray
;
public
Sub
(
String
attrName
,
PwrtRefId
refid
,
int
id
,
int
typeId
,
int
subscriptionsIndex
,
int
valueInt
,
float
valueFloat
,
boolean
valueBoolean
,
String
valueString
)
{
/*
this.refid = refid;
this.id = id;
this.sts = 0;
this.typeId = typeId;
*/
super
(
refid
,
id
,
0
,
typeId
);
this
.
subscriptionsIndex
=
subscriptionsIndex
;
this
.
valueInt
=
valueInt
;
...
...
@@ -69,25 +63,20 @@
public
Sub
(
String
attrName
,
PwrtRefId
refid
,
int
id
,
int
typeId
,
int
subscriptionsIndex
)
public
Sub
(
String
attrName
,
PwrtRefId
refid
,
int
id
,
int
typeId
,
int
subscriptionsIndex
,
int
elements
,
int
size
)
{
/*
this.refid = refid;
this.id = id;
this.sts = sts;
this.typeId = typeId;
*/
super
(
refid
,
id
,
0
,
typeId
);
super
(
refid
,
id
,
0
,
typeId
,
elements
,
size
);
this
.
attrName
=
attrName
;
this
.
subscriptionsIndex
=
subscriptionsIndex
;
}
//public boolean evenSts() { return (sts % 2 == 0);}
//public boolean oddSts() { return (sts % 2 == 1);}
//public int getSts() { return sts;}
int
getIndex
()
{
return
subscriptionsIndex
;
}
}
src/jpwr/rt/src/SubElement.java
View file @
a27529a3
...
...
@@ -11,7 +11,7 @@
{
public
int
[]
reffedByThread
;
public
BitSet
reffedByThreadBitSet
;
Sub
sub
=
new
Sub
(
" "
,
new
PwrtRefId
(
0
,
0
),
0
,
0
,
0
);
Sub
sub
=
new
Sub
(
" "
,
new
PwrtRefId
(
0
,
0
),
0
,
0
,
0
,
0
,
0
);
public
SubElement
(
int
maxConnections
,
int
threadNumber
)
...
...
@@ -40,6 +40,8 @@
this
.
sub
.
id
=
obj
.
id
;
this
.
sub
.
sts
=
obj
.
sts
;
this
.
sub
.
typeId
=
obj
.
typeId
;
this
.
sub
.
size
=
obj
.
size
;
this
.
sub
.
elements
=
obj
.
elements
;
this
.
sub
.
subscriptionsIndex
=
subscriptionsIndex
;
}
...
...
@@ -48,3 +50,4 @@
return
(
this
.
sub
.
attrName
.
equalsIgnoreCase
(((
SubElement
)
o
).
sub
.
attrName
)
&&
(((
SubElement
)
o
).
sub
.
sts
!=
0
));
}
}
src/jpwr/rt_client/src/Gdh.java
View file @
a27529a3
...
...
@@ -52,6 +52,13 @@ public class Gdh
public
final
static
int
GET_PARENT
=
44
;
public
final
static
int
GET_OBJECT_INFO_OBJID
=
45
;
public
final
static
int
GET_OBJECT_REF_INFO_BOOLEAN_ARRAY
=
46
;
public
final
static
int
GET_OBJECT_REF_INFO_FLOAT_ARRAY
=
47
;
public
final
static
int
GET_OBJECT_REF_INFO_INT_ARRAY
=
48
;
public
final
static
int
GET_OBJECT_REF_INFO_STRING_ARRAY
=
49
;
public
final
static
int
__IO_EXCEPTION
=
2000
;
public
final
static
int
__BUSY
=
2002
;
public
final
static
int
__UNREFED
=
0
;
...
...
@@ -367,7 +374,7 @@ public class Gdh
return
new
GdhrRefObjectInfo
(
null
,
0
,
0
,
0
);
}
//qqq
Sub
sub
=
new
Sub
(
attributeName
,
null
,
0
,
typeId
,
subscriptionCount
);
Sub
sub
=
new
Sub
(
attributeName
,
null
,
0
,
typeId
,
subscriptionCount
,
0
,
0
);
subscriptions
.
insertElementAt
(
sub
,
subscriptionCount
);
subscriptionCount
++;
return
new
GdhrRefObjectInfo
(
refid
,
id
,
1
,
typeId
);
...
...
@@ -395,13 +402,15 @@ public class Gdh
PwrtRefId
refid
=
new
PwrtRefId
(
rix
,
nid
);
int
id
=
in
.
readInt
();
int
typeId
=
in
.
readInt
();
Sub
sub
=
new
Sub
(
attributeName
,
refid
,
id
,
typeId
,
subscriptionCount
);
int
size
=
in
.
readInt
();
int
elements
=
in
.
readInt
();
Sub
sub
=
new
Sub
(
attributeName
,
refid
,
id
,
typeId
,
subscriptionCount
,
size
,
elements
);
sub
.
sts
=
1
;
subscriptions
.
insertElementAt
(
sub
,
id
);
subscriptionCount
++;
refid
=
new
PwrtRefId
(
id
,
0
);
subLate
++;
return
new
GdhrRefObjectInfo
(
refid
,
id
,
sts
,
typeId
);
return
new
GdhrRefObjectInfo
(
refid
,
id
,
sts
,
typeId
,
size
,
elements
);
}
catch
(
IOException
e
)
{
...
...
@@ -420,6 +429,7 @@ public class Gdh
int
nid
;
int
id
;
int
typeId
;
PwrtRefId
refid
;
if
(
listSent
)
...
...
@@ -472,6 +482,8 @@ public class Gdh
sub
.
refid
=
new
PwrtRefId
(
rix
,
nid
);
id
=
in
.
readInt
();
typeId
=
in
.
readInt
();
sub
.
size
=
in
.
readInt
();
sub
.
elements
=
in
.
readInt
();
}
locked
=
false
;
notify
();
...
...
@@ -540,8 +552,7 @@ public class Gdh
}
ret
.
id
=
ret
.
refid
.
rix
;
subscriptions
.
add
(
ret
);
//((Sub)retVec.get(i)).refid.rix = ((Sub)retVec.get(i)).id;
//System.out.println("Status " + ((Sub)retVec.get(i)).getSts());
}
subscriptionCount
+=
retVec
.
size
();
...
...
@@ -591,17 +602,24 @@ public class Gdh
//System.out.println("ArrayIndexOutOfBounds getObjectRefInfoFloat");
return
0
F
;
}
/*
try {
out.writeInt( GET_OBJECT_REF_INFO_FLOAT);
out.writeInt( id);
return in.readFloat();
} catch (IOException e) {
return 0F;
}
*/
}
public
float
[]
getObjectRefInfoFloatArray
(
int
id
,
int
elements
)
{
try
{
Sub
sub
=
(
Sub
)
subscriptions
.
elementAt
(
id
);
if
(
sub
.
oddSts
())
{
return
sub
.
valueFloatArray
;
}
return
null
;
}
catch
(
ArrayIndexOutOfBoundsException
e
)
{
//System.out.println("ArrayIndexOutOfBounds getObjectRefInfoFloat");
return
null
;
}
}
public
boolean
getObjectRefInfoBoolean
(
int
id
)
{
...
...
@@ -619,45 +637,61 @@ public class Gdh
//System.out.println("ArrayIndexOutOfBounds getObjectRefInfoBoolean");
return
false
;
}
/*
try {
out.writeInt( GET_OBJECT_REF_INFO_BOOLEAN);
out.writeInt( id);
return in.readBoolean();
} catch (IOException e) {
return false;
}
*/
}
public
int
getObjectRefInfoInt
(
int
id
)
public
boolean
[]
getObjectRefInfoBooleanArray
(
int
id
,
int
elements
)
{
try
{
Sub
sub
=
(
Sub
)
subscriptions
.
elementAt
(
id
);
if
(
sub
.
oddSts
())
Sub
sub
=
(
Sub
)
subscriptions
.
elementAt
(
id
);
if
(
sub
.
oddSts
())
{
return
sub
.
valueBooleanArray
;
}
return
null
;
}
catch
(
ArrayIndexOutOfBoundsException
e
)
{
return
sub
.
valueInt
;
//System.out.println("ArrayIndexOutOfBounds getObjectRefInfoBoolean");
return
null
;
}
return
0
;
}
public
int
getObjectRefInfoInt
(
int
id
)
{
try
{
Sub
sub
=
(
Sub
)
subscriptions
.
elementAt
(
id
);
if
(
sub
.
oddSts
())
{
return
sub
.
valueInt
;
}
return
0
;
}
catch
(
ArrayIndexOutOfBoundsException
e
)
catch
(
ArrayIndexOutOfBoundsException
e
)
{
//System.out.println("ArrayIndexOutOfBounds getObjectRefInfoInt");
return
0
;
}
/*
try {
out.writeInt( GET_OBJECT_REF_INFO_INT);
out.writeInt( id);
return in.readInt();
} catch (IOException e) {
return 0;
}
*/
}
public
int
[]
getObjectRefInfoIntArray
(
int
id
,
int
elements
)
{
try
{
Sub
sub
=
(
Sub
)
subscriptions
.
elementAt
(
id
);
if
(
sub
.
oddSts
())
{
return
sub
.
valueIntArray
;
}
return
null
;
}
catch
(
ArrayIndexOutOfBoundsException
e
)
{
//System.out.println("ArrayIndexOutOfBounds getObjectRefInfoInt");
return
null
;
}
}
public
String
getObjectRefInfoString
(
int
id
,
int
typeid
)
{
...
...
@@ -677,19 +711,31 @@ public class Gdh
//System.out.println("ArrayIndexOutOfBounds getObjectRefInfoString index " + id);
return
" "
;
}
/*
try {
out.writeInt( GET_OBJECT_REF_INFO_STRING);
out.writeInt( id);
out.writeInt( typeid);
return in.readUTF();
} catch (IOException e) {
return "";
}
public
String
[]
getObjectRefInfoStringArray
(
int
id
,
int
typeid
,
int
size
,
int
elements
)
{
try
{
Sub
sub
=
(
Sub
)
subscriptions
.
elementAt
(
id
);
if
(
sub
.
evenSts
()
||
sub
.
valueStringArray
==
null
)
{
if
(
sub
.
evenSts
())
System
.
out
.
println
(
"getObjectRefInfoString substs "
+
sub
.
getSts
()
+
" id "
+
id
);
return
null
;
}
return
sub
.
valueStringArray
;
}
catch
(
ArrayIndexOutOfBoundsException
e
)
{
//System.out.println("ArrayIndexOutOfBounds getObjectRefInfoString index " + id);
return
null
;
}
*/
}
public
synchronized
PwrtStatus
unrefObjectInfo
(
PwrtRefId
refid
)
{
try
...
...
@@ -1231,36 +1277,8 @@ public class Gdh
out
.
writeInt
(
GET_OBJECT_REF_INFO_ALL
);
out
.
flush
();
//Object retArray[] = (Object[])in.readObject();
//Object retArray[] = (Object[])inbuff.readObject();
//Object ret[] = (Object[])retArray[0];
//String sVec[] = (String[])retArray[0];
//boolean bVec[] = (boolean[])retArray[1];
//int iVec[] = (int[])retArray[2];
//float fVec[] = (float[])retArray[3];
/*
int thSubSize = in.readInt();
Object ret[] = (Object[])in.readObject();
*/
//subscriptions.clear();
//subscriptions.setSize(ret.length);
/*
String sVec[] = (String[])in.readObject();
boolean bVec[] = (boolean[])in.readObject();
int iVec[] = (int[])in.readObject();
float fVec[] = (float[])in.readObject();
*/
for
(
int
i
=
0
;
i
<
subscriptions
.
size
();
i
++)
{
//subscriptions.set(i, (jpwr.rt.Sub)ret[i]);
/*
((jpwr.rt.Sub)(subscriptions.get(i))).valueString = sVec[i];
((jpwr.rt.Sub)(subscriptions.get(i))).valueBoolean = bVec[i];
((jpwr.rt.Sub)(subscriptions.get(i))).valueInt = iVec[i];
((jpwr.rt.Sub)(subscriptions.get(i))).valueFloat = fVec[i];
*/
try
{
...
...
@@ -1645,24 +1663,11 @@ public class Gdh
return
0
;
}
/*
private class Sub extends GdhrRefObjectInfo implements Serializable
{
String attrName;
int subscriptionsIndex;
int valueInt;
float valueFloat;
boolean valueBoolean;
String valueString;
}
public Sub(String attrName, PwrtRefId refid, int id, int typeId, int subscriptionsIndex)
{
super(refid, id, 0, typeId);
this.attrName = attrName;
this.subscriptionsIndex = subscriptionsIndex;
}
}
*/
}
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