Commit 0d5bcba0 authored by Claes Sjofors's avatar Claes Sjofors

js alarm and eventlist added

parent f2be704e
...@@ -1784,6 +1784,9 @@ static void gdh_TranslateSuffixToClassData ( ...@@ -1784,6 +1784,9 @@ static void gdh_TranslateSuffixToClassData (
*PwrType = pwr_eType_Float32; *PwrType = pwr_eType_Float32;
*PwrSize = 4; *PwrSize = 4;
if (!str_NoCaseStrncmp("BIT", SuffixPtr, 3))
*(SuffixPtr + 3) = 0;
for (Index = 0, Found = FALSE; Index < XlationTblLen; Index++) for (Index = 0, Found = FALSE; Index < XlationTblLen; Index++)
if (!str_NoCaseStrcmp(XlationTbl[Index].TypeStr,SuffixPtr)) if (!str_NoCaseStrcmp(XlationTbl[Index].TypeStr,SuffixPtr))
{ {
...@@ -1799,6 +1802,7 @@ static void gdh_TranslateSuffixToClassData ( ...@@ -1799,6 +1802,7 @@ static void gdh_TranslateSuffixToClassData (
*PwrType = pwr_eType_String; *PwrType = pwr_eType_String;
} }
if ( Ptr != NULL && *NoOfElements > 1) if ( Ptr != NULL && *NoOfElements > 1)
{ {
*PwrSize *= *NoOfElements; *PwrSize *= *NoOfElements;
......
...@@ -53,8 +53,11 @@ ...@@ -53,8 +53,11 @@
pwr_tStatus ev_mh_ack_bc( mh_sAck *MsgP); pwr_tStatus ev_mh_ack_bc( mh_sAck *MsgP);
pwr_tStatus ev_mh_return_bc( mh_sReturn *MsgP); pwr_tStatus ev_mh_return_bc( mh_sReturn *MsgP);
pwr_tStatus ev_mh_alarm_bc( mh_sMessage *MsgP); pwr_tStatus ev_mh_alarm_bc( mh_sMessage *MsgP);
pwr_tStatus ev_mh_block_bc( mh_sBlock *MsgP);
pwr_tStatus ev_mh_cancel_bc( mh_sReturn *MsgP);
pwr_tStatus ev_mh_info_bc( mh_sMessage *MsgP); pwr_tStatus ev_mh_info_bc( mh_sMessage *MsgP);
pwr_tStatus ev_mh_clear_alarmlist_bc( pwr_tNodeIndex nix); pwr_tStatus ev_mh_clear_alarmlist_bc( pwr_tNodeIndex nix);
pwr_tStatus ev_mh_clear_blocklist_bc( pwr_tNodeIndex nix);
jclass Mh_id; jclass Mh_id;
jmethodID Mh_messReceived_id; jmethodID Mh_messReceived_id;
...@@ -73,7 +76,7 @@ JNIEXPORT void JNICALL Java_jpwr_rt_Mh_initIDs ...@@ -73,7 +76,7 @@ JNIEXPORT void JNICALL Java_jpwr_rt_Mh_initIDs
} }
//hmta pekare till staticmetoden messReceived //hmta pekare till staticmetoden messReceived
Mh_messReceived_id = (*env)->GetStaticMethodID( env, Mh_id, "messReceived", Mh_messReceived_id = (*env)->GetStaticMethodID( env, Mh_id, "messReceived",
"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;IIIILjava/lang/String;IILjava/lang/String;IILjpwr/rt/PwrtObjid;)V"); "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;IIIILjava/lang/String;IILjava/lang/String;IILjpwr/rt/PwrtAttrRef;Ljpwr/rt/PwrtAttrRef;Ljava/lang/String;)V");
sts = (*env)->GetJavaVM(env, &jvm); sts = (*env)->GetJavaVM(env, &jvm);
if(sts) if(sts)
{ {
...@@ -226,10 +229,10 @@ JNIEXPORT jobject JNICALL Java_jpwr_rt_Mh_outunitConnect ...@@ -226,10 +229,10 @@ JNIEXPORT jobject JNICALL Java_jpwr_rt_Mh_outunitConnect
mh_mOutunitFlags_ReadWait, mh_mOutunitFlags_ReadWait,
ev_mh_ack_bc, ev_mh_ack_bc,
ev_mh_alarm_bc, ev_mh_alarm_bc,
NULL, ev_mh_block_bc,
NULL, ev_mh_return_bc,
ev_mh_clear_alarmlist_bc, ev_mh_clear_alarmlist_bc,
NULL, ev_mh_clear_blocklist_bc,
ev_mh_info_bc, ev_mh_info_bc,
ev_mh_return_bc, ev_mh_return_bc,
NULL NULL
...@@ -309,35 +312,40 @@ JNIEXPORT jobject JNICALL Java_jpwr_rt_Mh_outunitReceive ...@@ -309,35 +312,40 @@ JNIEXPORT jobject JNICALL Java_jpwr_rt_Mh_outunitReceive
} }
/*frn xtt_ev.cpp*/
pwr_tStatus ev_mh_ack_bc( mh_sAck *MsgP) pwr_tStatus ev_mh_ack_bc( mh_sAck *MsgP)
{ {
JNIEnv *env; JNIEnv *env;
jclass PwrtObjid_id; jclass PwrtObjid_id;
jmethodID PwrtObjid_cid; jmethodID PwrtObjid_cid;
jobject objid_obj = NULL; jobject objid_obj = NULL;
jobject supobjid_obj = NULL;
jclass PwrtAttrRef_id;
jmethodID PwrtAttrRef_cid;
jobject attrref_obj = NULL;
jobject supattrref_obj = NULL;
jstring jevText; jstring jevText;
jstring jevName; jstring jevName;
jstring jevTime; jstring jevTime;
jstring jevBirthTime; jstring jevBirthTime;
jstring jevMoreText;
jint jevFlags; jint jevFlags;
jint jevPrio; jint jevPrio;
jint jevStatus; jint jevStatus;
jint jevNix; jint jevNix;
jint jevIdx; jint jevIdx;
jint jevType;
jint oix, vid;
jint body, offset, size, flags;
jstring jevTargetBirthTime; jstring jevTargetBirthTime;
jint jevTargetNix; jint jevTargetNix = (jint) 0;
jint jevTargetIdx; jint jevTargetIdx = (jint) 0;
char targetBirthTime_str[40];
jint jevType;
jint oix, vid;
char time_str[40]; char time_str[40];
char birthTime_str[40]; char birthTime_str[40];
pwr_tObjid objid = MsgP->SupObject.Objid; char targetBirthTime_str[40];
pwr_tTime time = net_NetTimeToTime( &MsgP->Info.EventTime); pwr_tTime time = net_NetTimeToTime( &MsgP->Info.EventTime);
pwr_tTime birthTime = net_NetTimeToTime( &MsgP->Info.Id.BirthTime); pwr_tTime birthTime = net_NetTimeToTime( &MsgP->Info.Id.BirthTime);
...@@ -347,50 +355,70 @@ pwr_tStatus ev_mh_ack_bc( mh_sAck *MsgP) ...@@ -347,50 +355,70 @@ pwr_tStatus ev_mh_ack_bc( mh_sAck *MsgP)
(*jvm)->AttachCurrentThread(jvm,(void **)&env,NULL); (*jvm)->AttachCurrentThread(jvm,(void **)&env,NULL);
if(env == NULL) printf("env r null"); if(env == NULL) printf("env r null");
PwrtObjid_id = (*env)->FindClass( env, "jpwr/rt/PwrtObjid"); PwrtObjid_id = (*env)->FindClass( env, "jpwr/rt/PwrtObjid");
PwrtObjid_cid = (*env)->GetMethodID( env, PwrtObjid_id, PwrtObjid_cid = (*env)->GetMethodID( env, PwrtObjid_id,
"<init>", "(II)V"); "<init>", "(II)V");
oix = (jint) objid.oix; PwrtAttrRef_id = (*env)->FindClass( env, "jpwr/rt/PwrtAttrRef");
vid = (jint) objid.vid; PwrtAttrRef_cid = (*env)->GetMethodID( env, PwrtAttrRef_id,
"<init>", "(Ljpwr/rt/PwrtObjid;IIII)V");
oix = (jint) MsgP->Object.Objid.oix;
vid = (jint) MsgP->Object.Objid.vid;
objid_obj = (*env)->NewObject( env, PwrtObjid_id, PwrtObjid_cid, objid_obj = (*env)->NewObject( env, PwrtObjid_id, PwrtObjid_cid,
oix, vid); oix, vid);
body = (jint) MsgP->Object.Body;
offset = (jint) MsgP->Object.Offset;
size = (jint) MsgP->Object.Size;
flags = (jint) MsgP->Object.Flags.m;
attrref_obj = (*env)->NewObject( env, PwrtAttrRef_id, PwrtAttrRef_cid,
objid_obj, body, offset, size, flags);
oix = (jint) MsgP->SupObject.Objid.oix;
vid = (jint) MsgP->SupObject.Objid.vid;
supobjid_obj = (*env)->NewObject( env, PwrtObjid_id, PwrtObjid_cid,
oix, vid);
body = (jint) MsgP->SupObject.Body;
offset = (jint) MsgP->SupObject.Offset;
size = (jint) MsgP->SupObject.Size;
flags = (jint) MsgP->SupObject.Flags.m;
supattrref_obj = (*env)->NewObject( env, PwrtAttrRef_id, PwrtAttrRef_cid,
supobjid_obj, body, offset, size, flags);
time_AtoAscii( &time, time_eFormat_ComprDateAndTime, time_str, sizeof(time_str)); time_AtoAscii( &time, time_eFormat_ComprDateAndTime, time_str, sizeof(time_str));
time_AtoAscii( &birthTime, time_eFormat_ComprDateAndTime, birthTime_str, sizeof(birthTime_str)); time_AtoAscii( &birthTime, time_eFormat_ComprDateAndTime, birthTime_str, sizeof(birthTime_str));
time_AtoAscii( &targetBirthTime, time_eFormat_ComprDateAndTime, targetBirthTime_str, sizeof(targetBirthTime_str)); time_AtoAscii( &targetBirthTime, time_eFormat_ComprDateAndTime, targetBirthTime_str, sizeof(targetBirthTime_str));
//gr om till Java-strngar // Convert to java strings
jevText = (*env)->NewStringUTF( env, " "); //eventText anvnds inte vid ack jevText = (*env)->NewStringUTF( env, ""); // Not used in ack
jevName = (*env)->NewStringUTF( env, MsgP->EventName); jevName = (*env)->NewStringUTF( env, MsgP->EventName);
jevTime = (*env)->NewStringUTF( env, time_str); jevTime = (*env)->NewStringUTF( env, time_str);
jevBirthTime = (*env)->NewStringUTF( env, birthTime_str); jevBirthTime = (*env)->NewStringUTF( env, birthTime_str);
jevTargetBirthTime = (*env)->NewStringUTF( env, targetBirthTime_str); jevTargetBirthTime = (*env)->NewStringUTF( env, targetBirthTime_str);
jevMoreText = (*env)->NewStringUTF( env, ""); // Not used in ack
//gr om till Java-int // Convert to java int
jevFlags = (jint)MsgP->Info.EventFlags; jevFlags = (jint)MsgP->Info.EventFlags;
jevPrio = (jint)MsgP->Info.EventPrio; jevPrio = (jint)MsgP->Info.EventPrio;
jevStatus = (jint)1; //finns ej i mh_sAck och anvnds ej heller jevStatus = (jint)1; // Not used in ack
jevNix = (jint)MsgP->Info.Id.Nix; jevNix = (jint)MsgP->Info.Id.Nix;
jevIdx = (jint)MsgP->Info.Id.Idx; jevIdx = (jint)MsgP->Info.Id.Idx;
jevType = (jint)MsgP->Info.EventType;
jevTargetNix = (jint)MsgP->TargetId.Nix; jevTargetNix = (jint)MsgP->TargetId.Nix;
jevTargetIdx = (jint)MsgP->TargetId.Idx; jevTargetIdx = (jint)MsgP->TargetId.Idx;
jevType = (jint)MsgP->Info.EventType; // Call the callback method in the Mh class
//anropa callback metoden i Mh-klassen
(*env)->CallStaticVoidMethod( env, Mh_id, Mh_messReceived_id, jevText, jevName, (*env)->CallStaticVoidMethod( env, Mh_id, Mh_messReceived_id, jevText, jevName,
jevTime, jevFlags, jevPrio, jevStatus, jevNix, jevBirthTime, jevIdx, jevTime, jevFlags, jevPrio, jevStatus, jevNix, jevBirthTime, jevIdx,
jevTargetNix, jevTargetBirthTime, jevTargetIdx, jevTargetNix, jevTargetBirthTime, jevTargetIdx,
jevType, objid_obj); jevType, attrref_obj, supattrref_obj, jevMoreText);
//important:check if an exception was raised // Important, check if an exception was raised
if ((*env)->ExceptionCheck(env)) if ((*env)->ExceptionCheck(env)) {
{ printf("Exception in ack_bc\n");
printf("exception i ack\n");
return 1; return 1;
} }
...@@ -403,10 +431,16 @@ pwr_tStatus ev_mh_return_bc( mh_sReturn *MsgP) ...@@ -403,10 +431,16 @@ pwr_tStatus ev_mh_return_bc( mh_sReturn *MsgP)
jclass PwrtObjid_id; jclass PwrtObjid_id;
jmethodID PwrtObjid_cid; jmethodID PwrtObjid_cid;
jobject objid_obj = NULL; jobject objid_obj = NULL;
jobject supobjid_obj = NULL;
jclass PwrtAttrRef_id;
jmethodID PwrtAttrRef_cid;
jobject attrref_obj = NULL;
jobject supattrref_obj = NULL;
jstring jevText; jstring jevText;
jstring jevName; jstring jevName;
jstring jevTime; jstring jevTime;
jstring jevBirthTime; jstring jevBirthTime;
jstring jevMoreText;
jint jevFlags; jint jevFlags;
jint jevPrio; jint jevPrio;
jint jevStatus; jint jevStatus;
...@@ -414,18 +448,18 @@ pwr_tStatus ev_mh_return_bc( mh_sReturn *MsgP) ...@@ -414,18 +448,18 @@ pwr_tStatus ev_mh_return_bc( mh_sReturn *MsgP)
jint jevIdx; jint jevIdx;
jint jevType; jint jevType;
jint oix, vid; jint oix, vid;
jint body, offset, size, flags;
jstring jevTargetBirthTime; jstring jevTargetBirthTime;
jint jevTargetNix; jint jevTargetNix;
jint jevTargetIdx; jint jevTargetIdx;
char targetBirthTime_str[40];
char time_str[40]; char time_str[40];
char birthTime_str[40]; char birthTime_str[40];
char targetBirthTime_str[40];
pwr_tObjid objid = MsgP->Object.Objid;
pwr_tTime time = net_NetTimeToTime( &MsgP->Info.EventTime); pwr_tTime time = net_NetTimeToTime( &MsgP->Info.EventTime);
pwr_tTime birthTime = net_NetTimeToTime( &MsgP->Info.Id.BirthTime); pwr_tTime birthTime = net_NetTimeToTime( &MsgP->Info.Id.BirthTime);
pwr_tTime targetBirthTime = net_NetTimeToTime( &MsgP->TargetId.BirthTime); pwr_tTime targetBirthTime = net_NetTimeToTime( &MsgP->TargetId.BirthTime);
...@@ -438,45 +472,65 @@ pwr_tStatus ev_mh_return_bc( mh_sReturn *MsgP) ...@@ -438,45 +472,65 @@ pwr_tStatus ev_mh_return_bc( mh_sReturn *MsgP)
PwrtObjid_cid = (*env)->GetMethodID( env, PwrtObjid_id, PwrtObjid_cid = (*env)->GetMethodID( env, PwrtObjid_id,
"<init>", "(II)V"); "<init>", "(II)V");
oix = (jint) objid.oix; PwrtAttrRef_id = (*env)->FindClass( env, "jpwr/rt/PwrtAttrRef");
vid = (jint) objid.vid; PwrtAttrRef_cid = (*env)->GetMethodID( env, PwrtAttrRef_id,
"<init>", "(Ljpwr/rt/PwrtObjid;IIII)V");
oix = (jint) MsgP->Object.Objid.oix;
vid = (jint) MsgP->Object.Objid.vid;
objid_obj = (*env)->NewObject( env, PwrtObjid_id, PwrtObjid_cid, objid_obj = (*env)->NewObject( env, PwrtObjid_id, PwrtObjid_cid,
oix, vid); oix, vid);
body = (jint) MsgP->Object.Body;
offset = (jint) MsgP->Object.Offset;
size = (jint) MsgP->Object.Size;
flags = (jint) MsgP->Object.Flags.m;
attrref_obj = (*env)->NewObject( env, PwrtAttrRef_id, PwrtAttrRef_cid,
objid_obj, body, offset, size, flags);
oix = (jint) MsgP->SupObject.Objid.oix;
vid = (jint) MsgP->SupObject.Objid.vid;
supobjid_obj = (*env)->NewObject( env, PwrtObjid_id, PwrtObjid_cid,
oix, vid);
body = (jint) MsgP->SupObject.Body;
offset = (jint) MsgP->SupObject.Offset;
size = (jint) MsgP->SupObject.Size;
flags = (jint) MsgP->SupObject.Flags.m;
supattrref_obj = (*env)->NewObject( env, PwrtAttrRef_id, PwrtAttrRef_cid,
supobjid_obj, body, offset, size, flags);
time_AtoAscii( &time, time_eFormat_ComprDateAndTime, time_str, sizeof(time_str)); time_AtoAscii( &time, time_eFormat_ComprDateAndTime, time_str, sizeof(time_str));
time_AtoAscii( &birthTime, time_eFormat_ComprDateAndTime, birthTime_str, sizeof(birthTime_str)); time_AtoAscii( &birthTime, time_eFormat_ComprDateAndTime, birthTime_str, sizeof(birthTime_str));
time_AtoAscii( &targetBirthTime, time_eFormat_ComprDateAndTime, targetBirthTime_str, sizeof(targetBirthTime_str)); time_AtoAscii( &targetBirthTime, time_eFormat_ComprDateAndTime, targetBirthTime_str, sizeof(targetBirthTime_str));
//gr om till Java-strngar // Convert to java strings
jevText = (*env)->NewStringUTF( env, MsgP->EventText); jevText = (*env)->NewStringUTF( env, MsgP->EventText);
jevName = (*env)->NewStringUTF( env, MsgP->EventName); jevName = (*env)->NewStringUTF( env, MsgP->EventName);
jevTime = (*env)->NewStringUTF( env, time_str); jevTime = (*env)->NewStringUTF( env, time_str);
jevBirthTime = (*env)->NewStringUTF( env, birthTime_str); jevBirthTime = (*env)->NewStringUTF( env, birthTime_str);
jevTargetBirthTime = (*env)->NewStringUTF( env, targetBirthTime_str); jevTargetBirthTime = (*env)->NewStringUTF( env, targetBirthTime_str);
jevMoreText = (*env)->NewStringUTF( env, "");
// Convert to java int
//gr om till Java-int
jevFlags = (jint)MsgP->Info.EventFlags; jevFlags = (jint)MsgP->Info.EventFlags;
jevPrio = (jint)MsgP->Info.EventPrio; jevPrio = (jint)MsgP->Info.EventPrio;
jevStatus = (jint)1;//mh_sReturn har ingen status jevStatus = (jint)1; // Not used in return
jevNix = (jint)MsgP->Info.Id.Nix; jevNix = (jint)MsgP->Info.Id.Nix;
jevIdx = (jint)MsgP->Info.Id.Idx; jevIdx = (jint)MsgP->Info.Id.Idx;
jevType = (jint)MsgP->Info.EventType;
jevTargetNix = (jint)MsgP->TargetId.Nix; jevTargetNix = (jint)MsgP->TargetId.Nix;
jevTargetIdx = (jint)MsgP->TargetId.Idx; jevTargetIdx = (jint)MsgP->TargetId.Idx;
// Call the callback method in the Mh class
jevType = (jint)MsgP->Info.EventType;
//anropa callback metoden i Mh-klassen
(*env)->CallStaticVoidMethod( env, Mh_id, Mh_messReceived_id, jevText, jevName, (*env)->CallStaticVoidMethod( env, Mh_id, Mh_messReceived_id, jevText, jevName,
jevTime, jevFlags, jevPrio, jevStatus, jevNix, jevBirthTime, jevIdx, jevTime, jevFlags, jevPrio, jevStatus, jevNix, jevBirthTime, jevIdx,
jevTargetNix, jevTargetBirthTime, jevTargetIdx, jevTargetNix, jevTargetBirthTime, jevTargetIdx,
jevType, objid_obj); jevType, attrref_obj, supattrref_obj, jevMoreText);
//important:check if an exception was raised // Important, check if an exception was raised
if ((*env)->ExceptionCheck(env)) if ((*env)->ExceptionCheck(env)) {
{ printf("Exception in return_bc\n");
printf("exception i return\n");
return 1; return 1;
} }
...@@ -489,10 +543,16 @@ pwr_tStatus ev_mh_alarm_bc( mh_sMessage *MsgP) ...@@ -489,10 +543,16 @@ pwr_tStatus ev_mh_alarm_bc( mh_sMessage *MsgP)
jclass PwrtObjid_id; jclass PwrtObjid_id;
jmethodID PwrtObjid_cid; jmethodID PwrtObjid_cid;
jobject objid_obj = NULL; jobject objid_obj = NULL;
jobject supobjid_obj = NULL;
jclass PwrtAttrRef_id;
jmethodID PwrtAttrRef_cid;
jobject attrref_obj = NULL;
jobject supattrref_obj = NULL;
jstring jevText; jstring jevText;
jstring jevName; jstring jevName;
jstring jevTime; jstring jevTime;
jstring jevBirthTime; jstring jevBirthTime;
jstring jevMoreText;
jint jevFlags; jint jevFlags;
jint jevPrio; jint jevPrio;
jint jevStatus; jint jevStatus;
...@@ -500,17 +560,17 @@ pwr_tStatus ev_mh_alarm_bc( mh_sMessage *MsgP) ...@@ -500,17 +560,17 @@ pwr_tStatus ev_mh_alarm_bc( mh_sMessage *MsgP)
jint jevIdx; jint jevIdx;
jint jevType; jint jevType;
jint oix, vid; jint oix, vid;
jint body, offset, size, flags;
jstring jevTargetBirthTime; jstring jevTargetBirthTime;
jint jevTargetNix = (jint) 0; jint jevTargetNix;
jint jevTargetIdx = (jint) 0; jint jevTargetIdx;
char time_str[40]; char time_str[40];
char birthTime_str[40]; char birthTime_str[40];
pwr_tObjid objid = MsgP->Object.Objid;
pwr_tTime time = net_NetTimeToTime( &MsgP->Info.EventTime); pwr_tTime time = net_NetTimeToTime( &MsgP->Info.EventTime);
pwr_tTime birthTime = net_NetTimeToTime( &MsgP->Info.Id.BirthTime); pwr_tTime birthTime = net_NetTimeToTime( &MsgP->Info.Id.BirthTime);
...@@ -522,40 +582,175 @@ pwr_tStatus ev_mh_alarm_bc( mh_sMessage *MsgP) ...@@ -522,40 +582,175 @@ pwr_tStatus ev_mh_alarm_bc( mh_sMessage *MsgP)
PwrtObjid_cid = (*env)->GetMethodID( env, PwrtObjid_id, PwrtObjid_cid = (*env)->GetMethodID( env, PwrtObjid_id,
"<init>", "(II)V"); "<init>", "(II)V");
oix = (jint) objid.oix; PwrtAttrRef_id = (*env)->FindClass( env, "jpwr/rt/PwrtAttrRef");
vid = (jint) objid.vid; PwrtAttrRef_cid = (*env)->GetMethodID( env, PwrtAttrRef_id,
"<init>", "(Ljpwr/rt/PwrtObjid;IIII)V");
oix = (jint) MsgP->Object.Objid.oix;
vid = (jint) MsgP->Object.Objid.vid;
objid_obj = (*env)->NewObject( env, PwrtObjid_id, PwrtObjid_cid, objid_obj = (*env)->NewObject( env, PwrtObjid_id, PwrtObjid_cid,
oix, vid); oix, vid);
body = (jint) MsgP->Object.Body;
offset = (jint) MsgP->Object.Offset;
size = (jint) MsgP->Object.Size;
flags = (jint) MsgP->Object.Flags.m;
attrref_obj = (*env)->NewObject( env, PwrtAttrRef_id, PwrtAttrRef_cid,
objid_obj, body, offset, size, flags);
oix = (jint) MsgP->SupObject.Objid.oix;
vid = (jint) MsgP->SupObject.Objid.vid;
supobjid_obj = (*env)->NewObject( env, PwrtObjid_id, PwrtObjid_cid,
oix, vid);
body = (jint) MsgP->SupObject.Body;
offset = (jint) MsgP->SupObject.Offset;
size = (jint) MsgP->SupObject.Size;
flags = (jint) MsgP->SupObject.Flags.m;
supattrref_obj = (*env)->NewObject( env, PwrtAttrRef_id, PwrtAttrRef_cid,
supobjid_obj, body, offset, size, flags);
time_AtoAscii( &time, time_eFormat_ComprDateAndTime, time_str, sizeof(time_str)); time_AtoAscii( &time, time_eFormat_ComprDateAndTime, time_str, sizeof(time_str));
time_AtoAscii( &birthTime, time_eFormat_ComprDateAndTime, birthTime_str, sizeof(birthTime_str)); time_AtoAscii( &birthTime, time_eFormat_ComprDateAndTime, birthTime_str, sizeof(birthTime_str));
//gr om till Java-strngar // Convert to java strings
jevText = (*env)->NewStringUTF( env, MsgP->EventText); jevText = (*env)->NewStringUTF( env, MsgP->EventText);
jevName = (*env)->NewStringUTF( env, MsgP->EventName); jevName = (*env)->NewStringUTF( env, MsgP->EventName);
jevTime = (*env)->NewStringUTF( env, time_str); jevTime = (*env)->NewStringUTF( env, time_str);
jevBirthTime = (*env)->NewStringUTF( env, birthTime_str); jevBirthTime = (*env)->NewStringUTF( env, birthTime_str);
jevTargetBirthTime = (*env)->NewStringUTF( env, "");
jevMoreText = (*env)->NewStringUTF( env, MsgP->EventMoreText);
// Convert to java int
jevFlags = (jint)MsgP->Info.EventFlags;
jevPrio = (jint)MsgP->Info.EventPrio;
jevStatus = (jint)MsgP->Status;
jevNix = (jint)MsgP->Info.Id.Nix;
jevIdx = (jint)MsgP->Info.Id.Idx;
jevType = (jint)MsgP->Info.EventType;
jevTargetNix = (jint)0;
jevTargetIdx = (jint)0;
// Call the callback method in the Mh class
(*env)->CallStaticVoidMethod( env, Mh_id, Mh_messReceived_id, jevText, jevName,
jevTime, jevFlags, jevPrio, jevStatus, jevNix, jevBirthTime, jevIdx,
jevTargetNix, jevTargetBirthTime, jevTargetIdx,
jevType, attrref_obj, supattrref_obj, jevMoreText);
// Important, check if an exception was raised
if ((*env)->ExceptionCheck(env)) {
printf("Exception in alarm_bc\n");
return 1;
}
return 1;
}
pwr_tStatus ev_mh_block_bc( mh_sBlock *MsgP)
{
JNIEnv *env;
jclass PwrtObjid_id;
jmethodID PwrtObjid_cid;
jobject objid_obj = NULL;
jobject supobjid_obj = NULL;
jclass PwrtAttrRef_id;
jmethodID PwrtAttrRef_cid;
jobject attrref_obj = NULL;
jobject supattrref_obj = NULL;
jstring jevText;
jstring jevName;
jstring jevTime;
jstring jevBirthTime;
jstring jevMoreText;
jint jevFlags;
jint jevPrio;
jint jevStatus;
jint jevNix;
jint jevIdx;
jint jevType;
jint oix, vid;
jint body, offset, size, flags;
jstring jevTargetBirthTime;
jint jevTargetNix;
jint jevTargetIdx;
jevTargetBirthTime = (*env)->NewStringUTF( env, " ");
char time_str[40];
char birthTime_str[40];
pwr_tTime time = net_NetTimeToTime( &MsgP->Info.EventTime);
pwr_tTime birthTime = net_NetTimeToTime( &MsgP->Info.Id.BirthTime);
//hmta enviormentpekaren
(*jvm)->AttachCurrentThread(jvm,(void **)&env,NULL);
if(env == NULL) printf("env r null");
PwrtObjid_id = (*env)->FindClass( env, "jpwr/rt/PwrtObjid");
PwrtObjid_cid = (*env)->GetMethodID( env, PwrtObjid_id,
"<init>", "(II)V");
PwrtAttrRef_id = (*env)->FindClass( env, "jpwr/rt/PwrtAttrRef");
PwrtAttrRef_cid = (*env)->GetMethodID( env, PwrtAttrRef_id,
"<init>", "(Ljpwr/rt/PwrtObjid;IIII)V");
oix = (jint) MsgP->Object.Objid.oix;
vid = (jint) MsgP->Object.Objid.vid;
objid_obj = (*env)->NewObject( env, PwrtObjid_id, PwrtObjid_cid,
oix, vid);
//gr om till Java-int body = (jint) MsgP->Object.Body;
offset = (jint) MsgP->Object.Offset;
size = (jint) MsgP->Object.Size;
flags = (jint) MsgP->Object.Flags.m;
attrref_obj = (*env)->NewObject( env, PwrtAttrRef_id, PwrtAttrRef_cid,
objid_obj, body, offset, size, flags);
oix = (jint) MsgP->SupObject.Objid.oix;
vid = (jint) MsgP->SupObject.Objid.vid;
supobjid_obj = (*env)->NewObject( env, PwrtObjid_id, PwrtObjid_cid,
oix, vid);
body = (jint) MsgP->SupObject.Body;
offset = (jint) MsgP->SupObject.Offset;
size = (jint) MsgP->SupObject.Size;
flags = (jint) MsgP->SupObject.Flags.m;
supattrref_obj = (*env)->NewObject( env, PwrtAttrRef_id, PwrtAttrRef_cid,
supobjid_obj, body, offset, size, flags);
time_AtoAscii( &time, time_eFormat_ComprDateAndTime, time_str, sizeof(time_str));
time_AtoAscii( &birthTime, time_eFormat_ComprDateAndTime, birthTime_str, sizeof(birthTime_str));
// Convert to java strings
jevText = (*env)->NewStringUTF( env, "");
jevName = (*env)->NewStringUTF( env, MsgP->EventName);
jevTime = (*env)->NewStringUTF( env, time_str);
jevBirthTime = (*env)->NewStringUTF( env, birthTime_str);
jevTargetBirthTime = (*env)->NewStringUTF( env, "");
jevMoreText = (*env)->NewStringUTF( env, "");
// Convert to java int
jevFlags = (jint)MsgP->Info.EventFlags; jevFlags = (jint)MsgP->Info.EventFlags;
jevPrio = (jint)MsgP->Info.EventPrio; jevPrio = (jint)MsgP->Info.EventPrio;
jevStatus = (jint)MsgP->Status; jevStatus = (jint)MsgP->Status;
jevNix = (jint)MsgP->Info.Id.Nix; jevNix = (jint)MsgP->Info.Id.Nix;
jevIdx = (jint)MsgP->Info.Id.Idx; jevIdx = (jint)MsgP->Info.Id.Idx;
jevType = (jint)MsgP->Info.EventType; jevType = (jint)MsgP->Info.EventType;
//anropa callback metoden i Mh-klassen jevTargetNix = (jint)0;
jevTargetIdx = (jint)0;
// Call the callback method in the Mh class
(*env)->CallStaticVoidMethod( env, Mh_id, Mh_messReceived_id, jevText, jevName, (*env)->CallStaticVoidMethod( env, Mh_id, Mh_messReceived_id, jevText, jevName,
jevTime, jevFlags, jevPrio, jevStatus, jevNix, jevBirthTime, jevIdx, jevTime, jevFlags, jevPrio, jevStatus, jevNix, jevBirthTime, jevIdx,
jevTargetNix, jevTargetBirthTime, jevTargetIdx, jevTargetNix, jevTargetBirthTime, jevTargetIdx,
jevType, objid_obj); jevType, attrref_obj, supattrref_obj, jevMoreText);
//important:check if an exception was raised // Important, check if an exception was raised
if ((*env)->ExceptionCheck(env)) if ((*env)->ExceptionCheck(env)) {
{ printf("Exception in alarm_bc\n");
printf("exception i alarm\n");
return 1; return 1;
} }
...@@ -568,10 +763,16 @@ pwr_tStatus ev_mh_info_bc( mh_sMessage *MsgP) ...@@ -568,10 +763,16 @@ pwr_tStatus ev_mh_info_bc( mh_sMessage *MsgP)
jclass PwrtObjid_id; jclass PwrtObjid_id;
jmethodID PwrtObjid_cid; jmethodID PwrtObjid_cid;
jobject objid_obj = NULL; jobject objid_obj = NULL;
jobject supobjid_obj = NULL;
jclass PwrtAttrRef_id;
jmethodID PwrtAttrRef_cid;
jobject attrref_obj = NULL;
jobject supattrref_obj = NULL;
jstring jevText; jstring jevText;
jstring jevName; jstring jevName;
jstring jevTime; jstring jevTime;
jstring jevBirthTime; jstring jevBirthTime;
jstring jevMoreText;
jint jevFlags; jint jevFlags;
jint jevPrio; jint jevPrio;
jint jevStatus; jint jevStatus;
...@@ -579,16 +780,17 @@ pwr_tStatus ev_mh_info_bc( mh_sMessage *MsgP) ...@@ -579,16 +780,17 @@ pwr_tStatus ev_mh_info_bc( mh_sMessage *MsgP)
jint jevIdx; jint jevIdx;
jint jevType; jint jevType;
jint oix, vid; jint oix, vid;
jint body, offset, size, flags;
jstring jevTargetBirthTime; jstring jevTargetBirthTime;
jint jevTargetNix = (jint) 0; jint jevTargetNix;
jint jevTargetIdx = (jint) 0; jint jevTargetIdx;
char time_str[40]; char time_str[40];
char birthTime_str[40]; char birthTime_str[40];
pwr_tObjid objid = MsgP->Object.Objid;
pwr_tTime time = net_NetTimeToTime( &MsgP->Info.EventTime); pwr_tTime time = net_NetTimeToTime( &MsgP->Info.EventTime);
pwr_tTime birthTime = net_NetTimeToTime( &MsgP->Info.Id.BirthTime); pwr_tTime birthTime = net_NetTimeToTime( &MsgP->Info.Id.BirthTime);
...@@ -600,39 +802,65 @@ pwr_tStatus ev_mh_info_bc( mh_sMessage *MsgP) ...@@ -600,39 +802,65 @@ pwr_tStatus ev_mh_info_bc( mh_sMessage *MsgP)
PwrtObjid_cid = (*env)->GetMethodID( env, PwrtObjid_id, PwrtObjid_cid = (*env)->GetMethodID( env, PwrtObjid_id,
"<init>", "(II)V"); "<init>", "(II)V");
oix = (jint) objid.oix; PwrtAttrRef_id = (*env)->FindClass( env, "jpwr/rt/PwrtAttrRef");
vid = (jint) objid.vid; PwrtAttrRef_cid = (*env)->GetMethodID( env, PwrtAttrRef_id,
"<init>", "(Ljpwr/rt/PwrtObjid;IIII)V");
oix = (jint) MsgP->Object.Objid.oix;
vid = (jint) MsgP->Object.Objid.vid;
objid_obj = (*env)->NewObject( env, PwrtObjid_id, PwrtObjid_cid, objid_obj = (*env)->NewObject( env, PwrtObjid_id, PwrtObjid_cid,
oix, vid); oix, vid);
body = (jint) MsgP->Object.Body;
offset = (jint) MsgP->Object.Offset;
size = (jint) MsgP->Object.Size;
flags = (jint) MsgP->Object.Flags.m;
attrref_obj = (*env)->NewObject( env, PwrtAttrRef_id, PwrtAttrRef_cid,
objid_obj, body, offset, size, flags);
oix = (jint) MsgP->SupObject.Objid.oix;
vid = (jint) MsgP->SupObject.Objid.vid;
supobjid_obj = (*env)->NewObject( env, PwrtObjid_id, PwrtObjid_cid,
oix, vid);
body = (jint) MsgP->SupObject.Body;
offset = (jint) MsgP->SupObject.Offset;
size = (jint) MsgP->SupObject.Size;
flags = (jint) MsgP->SupObject.Flags.m;
supattrref_obj = (*env)->NewObject( env, PwrtAttrRef_id, PwrtAttrRef_cid,
supobjid_obj, body, offset, size, flags);
time_AtoAscii( &time, time_eFormat_ComprDateAndTime, time_str, sizeof(time_str)); time_AtoAscii( &time, time_eFormat_ComprDateAndTime, time_str, sizeof(time_str));
time_AtoAscii( &birthTime, time_eFormat_ComprDateAndTime, birthTime_str, sizeof(birthTime_str)); time_AtoAscii( &birthTime, time_eFormat_ComprDateAndTime, birthTime_str, sizeof(birthTime_str));
//gr om till Java-strngar // Convert to java strings
jevText = (*env)->NewStringUTF( env, MsgP->EventText); jevText = (*env)->NewStringUTF( env, MsgP->EventText);
jevName = (*env)->NewStringUTF( env, MsgP->EventName); jevName = (*env)->NewStringUTF( env, MsgP->EventName);
jevTime = (*env)->NewStringUTF( env, time_str); jevTime = (*env)->NewStringUTF( env, time_str);
jevBirthTime = (*env)->NewStringUTF( env, birthTime_str); jevBirthTime = (*env)->NewStringUTF( env, birthTime_str);
jevTargetBirthTime = (*env)->NewStringUTF( env, "");
jevMoreText = (*env)->NewStringUTF( env, MsgP->EventMoreText);
jevTargetBirthTime = (*env)->NewStringUTF( env, " ");
//gr om till Java-int // Convert to java int
jevFlags = (jint)MsgP->Info.EventFlags; jevFlags = (jint)MsgP->Info.EventFlags;
jevPrio = (jint)MsgP->Info.EventPrio; jevPrio = (jint)MsgP->Info.EventPrio;
jevStatus = (jint)MsgP->Status; jevStatus = (jint)MsgP->Status;
jevNix = (jint)MsgP->Info.Id.Nix; jevNix = (jint)MsgP->Info.Id.Nix;
jevIdx = (jint)MsgP->Info.Id.Idx; jevIdx = (jint)MsgP->Info.Id.Idx;
jevType = (jint)MsgP->Info.EventType; jevType = (jint)MsgP->Info.EventType;
//anropa callback metoden i Mh-klassen jevTargetNix = (jint)0;
jevTargetIdx = (jint)0;
// Call the callback method in the Mh class
(*env)->CallStaticVoidMethod( env, Mh_id, Mh_messReceived_id, jevText, jevName, (*env)->CallStaticVoidMethod( env, Mh_id, Mh_messReceived_id, jevText, jevName,
jevTime, jevFlags, jevPrio, jevStatus, jevNix, jevBirthTime, jevIdx, jevTime, jevFlags, jevPrio, jevStatus, jevNix, jevBirthTime, jevIdx,
jevTargetNix, jevTargetBirthTime, jevTargetIdx, jevTargetNix, jevTargetBirthTime, jevTargetIdx,
jevType, objid_obj); jevType, attrref_obj, supattrref_obj, jevMoreText);
//important:check if an exception was raised // Important, check if an exception was raised
if ((*env)->ExceptionCheck(env)) if ((*env)->ExceptionCheck(env)) {
{ printf("Exception in alarm_bc\n");
printf("exception i info\n");
return 1; return 1;
} }
...@@ -666,4 +894,9 @@ pwr_tStatus ev_mh_clear_alarmlist_bc( pwr_tNodeIndex nix) ...@@ -666,4 +894,9 @@ pwr_tStatus ev_mh_clear_alarmlist_bc( pwr_tNodeIndex nix)
return 1; return 1;
} }
pwr_tStatus ev_mh_clear_blocklist_bc( pwr_tNodeIndex nix) {
// TODO
return 1;
}
/*slut p frn xtt_ev.cpp*/ /*slut p frn xtt_ev.cpp*/
...@@ -58,6 +58,7 @@ import javax.swing.*; ...@@ -58,6 +58,7 @@ import javax.swing.*;
*/ */
public class GdhWebSocketServer public class GdhWebSocketServer
{ {
public final static int graph_eType_Bit = (1 << 15) + 1;
public final static int SET_OBJECT_INFO_BOOLEAN = 1; public final static int SET_OBJECT_INFO_BOOLEAN = 1;
public final static int SET_OBJECT_INFO_FLOAT = 2; public final static int SET_OBJECT_INFO_FLOAT = 2;
public final static int SET_OBJECT_INFO_INT = 3; public final static int SET_OBJECT_INFO_INT = 3;
...@@ -123,10 +124,15 @@ public class GdhWebSocketServer ...@@ -123,10 +124,15 @@ public class GdhWebSocketServer
public final static int GET_OBJECT = 63; public final static int GET_OBJECT = 63;
public final static int GET_OPWIND_MENU = 64; public final static int GET_OPWIND_MENU = 64;
public final static int GET_OBJECT_FROM_NAME = 65; public final static int GET_OBJECT_FROM_NAME = 65;
public final static int MH_SYNC = 66;
public final static int MH_ACK = 67;
public final static int GET_OBJECT_FROM_AREF = 68;
public final static int GET_OP_SELF = 1; public final static int GET_OP_SELF = 1;
public final static int GET_OP_METHOD_PLC = 2; public final static int GET_OP_METHOD_PLC = 2;
public final static int GET_OP_METHOD_OBJECTGRAPH = 3; public final static int GET_OP_METHOD_OBJECTGRAPH = 3;
public final static int GET_OP_METHOD_GRAPH = 4;
public final static int GET_OP_METHOD_HELPCLASS = 5;
public final static int PORT = 4448; public final static int PORT = 4448;
...@@ -143,13 +149,18 @@ public class GdhWebSocketServer ...@@ -143,13 +149,18 @@ public class GdhWebSocketServer
static int totalThreadCount = 0; static int totalThreadCount = 0;
Gdh gdh; Gdh gdh;
Errh errh; Errh errh;
Mh mh;
MhData mhData;
int maxConnections; int maxConnections;
String currentConnectionsStr; String currentConnectionsStr;
static boolean ignoreHandler = false; boolean[] connectionOccupied;
int maxAlarms;
int maxEvents;
PwrtObjid handlerOid = null;
static boolean log = false; static boolean log = false;
static boolean logRefInfoAll = false; static boolean logRefInfoAll = false;
static boolean logStatistics = false; static boolean logStatistics = false;
static boolean debug = true; static boolean debug = false;
static int lastIndexReffed = 0; static int lastIndexReffed = 0;
...@@ -170,10 +181,7 @@ public class GdhWebSocketServer ...@@ -170,10 +181,7 @@ public class GdhWebSocketServer
public static void main(String[] args) { public static void main(String[] args) {
System.out.println( "java.library.path = " + System.getProperty("java.library.path")); System.out.println( "java.library.path = " + System.getProperty("java.library.path"));
for( int i = 0; i < args.length; i++) { for( int i = 0; i < args.length; i++) {
if( args[i].equals("-i")) { if ( args[i].equals("-l")) {
ignoreHandler = true;
}
else if ( args[i].equals("-l")) {
log = true; log = true;
} }
else if ( args[i].equals("-logRefInfoAll")) { else if ( args[i].equals("-logRefInfoAll")) {
...@@ -208,10 +216,6 @@ public class GdhWebSocketServer ...@@ -208,10 +216,6 @@ public class GdhWebSocketServer
@return The handlerObject value @return The handlerObject value
*/ */
private int getHandlerObject() { private int getHandlerObject() {
if ( ignoreHandler) {
maxConnections = 50;
return 1;
}
CdhrObjid cdhrObjid; CdhrObjid cdhrObjid;
CdhrString cdhrString; CdhrString cdhrString;
CdhrInt cdhrInt; CdhrInt cdhrInt;
...@@ -221,7 +225,9 @@ public class GdhWebSocketServer ...@@ -221,7 +225,9 @@ public class GdhWebSocketServer
errh.info("No WebSocketServer is configured, WebSocketServer terminating"); errh.info("No WebSocketServer is configured, WebSocketServer terminating");
return cdhrObjid.getSts(); return cdhrObjid.getSts();
} }
cdhrString = gdh.objidToName(cdhrObjid.objid, Cdh.mName_volumeStrict); handlerOid = cdhrObjid.objid;
cdhrString = gdh.objidToName(handlerOid, Cdh.mName_volumeStrict);
if( cdhrString.evenSts()) if( cdhrString.evenSts())
return cdhrString.getSts(); return cdhrString.getSts();
...@@ -231,9 +237,30 @@ public class GdhWebSocketServer ...@@ -231,9 +237,30 @@ public class GdhWebSocketServer
return cdhrInt.getSts(); return cdhrInt.getSts();
maxConnections = cdhrInt.value; maxConnections = cdhrInt.value;
attr = cdhrString.str + ".MaxNoOfAlarms";
cdhrInt = gdh.getObjectInfoInt(attr);
if(cdhrInt.evenSts())
return cdhrInt.getSts();
maxAlarms = cdhrInt.value;
if (maxAlarms <= 0)
maxAlarms = 100;
attr = cdhrString.str + ".MaxNoOfEvents";
cdhrInt = gdh.getObjectInfoInt(attr);
if(cdhrInt.evenSts())
return cdhrInt.getSts();
maxEvents = cdhrInt.value;
if( maxEvents <= 0)
maxEvents = 200;
connectionOccupied = new boolean[maxConnections];
currentConnectionsStr = cdhrString.str + ".CurrentConnections"; currentConnectionsStr = cdhrString.str + ".CurrentConnections";
setCurrentConnections(threadCount); setCurrentConnections(threadCount);
errh.info("WebSocketServer started, MaxConnections: " + maxConnections); errh.info("WebSocketServer started, MaxConnections: " + maxConnections);
System.out.println("MaxConnections: " + maxConnections);
return 1; return 1;
} }
...@@ -246,7 +273,6 @@ public class GdhWebSocketServer ...@@ -246,7 +273,6 @@ public class GdhWebSocketServer
private void setCurrentConnections(int connections) { private void setCurrentConnections(int connections) {
PwrtStatus sts; PwrtStatus sts;
if(!ignoreHandler)
sts = gdh.setObjectInfo(currentConnectionsStr, connections); sts = gdh.setObjectInfo(currentConnectionsStr, connections);
} }
...@@ -280,11 +306,24 @@ public class GdhWebSocketServer ...@@ -280,11 +306,24 @@ public class GdhWebSocketServer
System.exit(0); System.exit(0);
} }
mh = new Mh((Object)null, maxAlarms, maxEvents);
mhData = new MhData(maxAlarms, maxEvents);
PwrtStatus stsM = mh.outunitConnect(handlerOid);
if(stsM.evenSts())
{
System.out.println("Fel vid outunitConnect");
errh.setStatus( Errh.PWR__SRVTERM);
return;
}
MhSendThread mhSendThread = new MhSendThread(mh);
errh.setStatus( Errh.PWR__SRUN); errh.setStatus( Errh.PWR__SRUN);
Qcom qcom = new Qcom(); Qcom qcom = new Qcom();
QcomrCreateQ qque = qcom.createIniEventQ("WebSocketServer"); QcomrCreateQ qque = qcom.createIniEventQ("WebSocketServer");
if( qque.evenSts()) { if( qque.evenSts()) {
errh.fatal("WebSocketServer couldn create EventQue"); errh.fatal("WebSocketServer couldn't create EventQue");
return; return;
} }
...@@ -315,14 +354,25 @@ public class GdhWebSocketServer ...@@ -315,14 +354,25 @@ public class GdhWebSocketServer
errh.error("Accept failed."); errh.error("Accept failed.");
continue; continue;
} }
if(threadCount <= maxConnections) { // Find free slot
int threadNumber = -1;
for ( int i = 0; i < maxConnections; i++) {
if ( !connectionOccupied[i]) {
threadNumber = i;
connectionOccupied[i] = true;
break;
}
}
if ( threadNumber >= 0) {
// Create a new thread // Create a new thread
System.out.println("New thread " + threadNumber);
threadCount++; threadCount++;
totalThreadCount++; totalThreadCount++;
setCurrentConnections(threadCount); setCurrentConnections(threadCount);
GdhThread gdhThread = new GdhThread(cliSocket, totalThreadCount, maxConnections); GdhThread gdhThread = new GdhThread(cliSocket, threadNumber, maxConnections);
} }
else { else {
System.out.println("Max number of threads exceeded");
errh.warning("Connection dismissed, max number of connections exceeded"); errh.warning("Connection dismissed, max number of connections exceeded");
try { try {
cliSocket.close(); cliSocket.close();
...@@ -335,6 +385,38 @@ public class GdhWebSocketServer ...@@ -335,6 +385,38 @@ public class GdhWebSocketServer
} }
private class MhSendThread extends Thread {
Mh mh;
boolean keepRunning = true;
public MhSendThread(Mh mh) {
this.mh = mh;
start();
}
public void run() {
PwrtStatus stsM = new PwrtStatus(0);
while (this.keepRunning) {
try {
if (mh.hasNewMessArrived()) {
MhrEvent newMess = mh.getNewMess();
synchronized(mhData) {
mhData.insertNewMess(newMess);
}
System.out.println("New mh message " + newMess.syncIdx + " " + newMess.eventId.idx + " " + newMess.eventText);
}
stsM = mh.outunitReceive();
Thread.sleep(1);
}
catch(Exception e) {
if(log)
System.out.println("Exception i run mhSendThread " + e.toString());
}
}
}
}
private class GdhThread extends Thread { private class GdhThread extends Thread {
Socket clientSocket; Socket clientSocket;
public Vector<Sub> thSub = new Vector<Sub>(); public Vector<Sub> thSub = new Vector<Sub>();
...@@ -362,7 +444,6 @@ public class GdhWebSocketServer ...@@ -362,7 +444,6 @@ public class GdhWebSocketServer
class SendSub extends TimerTask { class SendSub extends TimerTask {
public void run() { public void run() {
System.out.println( "SendSub");
int id = 5678; int id = 5678;
int sts = 123; int sts = 123;
int size = 0; int size = 0;
...@@ -414,6 +495,7 @@ public class GdhWebSocketServer ...@@ -414,6 +495,7 @@ public class GdhWebSocketServer
bb.putInt( j, 1); bb.putInt( j, 1);
j += 4; j += 4;
boolean value = gdh.getObjectRefInfoBoolean(sub.id); boolean value = gdh.getObjectRefInfoBoolean(sub.id);
if ( debug)
System.out.println( i + " Value: " + value + " Type " + sub.typeId + " " + (15+size) + " " + j); System.out.println( i + " Value: " + value + " Type " + sub.typeId + " " + (15+size) + " " + j);
bb.put( j, value ? (byte)1 : (byte)0); bb.put( j, value ? (byte)1 : (byte)0);
j += 1; j += 1;
...@@ -461,7 +543,6 @@ public class GdhWebSocketServer ...@@ -461,7 +543,6 @@ public class GdhWebSocketServer
Matcher get = Pattern.compile("^GET").matcher(data); Matcher get = Pattern.compile("^GET").matcher(data);
if ( get.find()) { if ( get.find()) {
System.out.println("Match GET");
Matcher match = Pattern.compile("Sec-WebSocket-Key: (.*)").matcher(data); Matcher match = Pattern.compile("Sec-WebSocket-Key: (.*)").matcher(data);
match.find(); match.find();
byte[] response = ("HTTP/1.1 101 Switching Protocols\r\n" byte[] response = ("HTTP/1.1 101 Switching Protocols\r\n"
...@@ -475,7 +556,6 @@ public class GdhWebSocketServer ...@@ -475,7 +556,6 @@ public class GdhWebSocketServer
.getBytes("UTF-8"))) .getBytes("UTF-8")))
+ "\r\n\r\n") + "\r\n\r\n")
.getBytes("UTF-8"); .getBytes("UTF-8");
System.out.println("Sending " + response);
out.write(response, 0, response.length); out.write(response, 0, response.length);
in = new BufferedInputStream(instream); in = new BufferedInputStream(instream);
...@@ -483,6 +563,7 @@ public class GdhWebSocketServer ...@@ -483,6 +563,7 @@ public class GdhWebSocketServer
} }
catch(IOException e) { catch(IOException e) {
errh.error("DataStream failed"); errh.error("DataStream failed");
connectionOccupied[threadNumber] = false;
threadCount--; threadCount--;
setCurrentConnections(threadCount); setCurrentConnections(threadCount);
return; return;
...@@ -507,13 +588,11 @@ public class GdhWebSocketServer ...@@ -507,13 +588,11 @@ public class GdhWebSocketServer
if ( size < 0) if ( size < 0)
continue; continue;
//System.out.println( "Received: " + c1 + " " + c2 + " " + size);
int[] key = new int[4]; int[] key = new int[4];
key[0] = in.read(); key[0] = in.read();
key[1] = in.read(); key[1] = in.read();
key[2] = in.read(); key[2] = in.read();
key[3] = in.read(); key[3] = in.read();
//System.out.println( "Key : " + key[0] + " " + key[1] + " " + key[2] + " " + key[3]);
switch ( opcode) { switch ( opcode) {
case 1: case 1:
...@@ -532,9 +611,13 @@ public class GdhWebSocketServer ...@@ -532,9 +611,13 @@ public class GdhWebSocketServer
value[i] = (byte)(c ^ key[i & 0x3]); value[i] = (byte)(c ^ key[i & 0x3]);
} }
int reason = ((value[1] & 0xFF) << 0) + ((value[0] & 0xFF) << 8); int reason = ((value[1] & 0xFF) << 0) + ((value[0] & 0xFF) << 8);
System.out.println( "Opcode 8, Connection closed, reason: " + reason); System.out.println( "Thread " + threadNumber + " closed, Opcode 8, reason: " + reason);
if ( timer != null) if ( timer != null)
timer.cancel(); timer.cancel();
connectionOccupied[threadNumber] = false;
threadCount--;
setCurrentConnections(threadCount);
return; return;
default: default:
System.out.println( "Unknown opcode: " + opcode); System.out.println( "Unknown opcode: " + opcode);
...@@ -548,8 +631,6 @@ public class GdhWebSocketServer ...@@ -548,8 +631,6 @@ public class GdhWebSocketServer
int id = ((value[2] & 0xFF) << 0) + ((value[3] & 0xFF) << 8) + ((value[4] & 0xFF) << 16) + ((value[5] & 0xFF) << 24); int id = ((value[2] & 0xFF) << 0) + ((value[3] & 0xFF) << 8) + ((value[4] & 0xFF) << 16) + ((value[5] & 0xFF) << 24);
//System.out.println( "id: " + id);
switch ( value[0]) { switch ( value[0]) {
case GET_OBJECT_INFO_BOOLEAN: case GET_OBJECT_INFO_BOOLEAN:
try { try {
...@@ -727,9 +808,7 @@ public class GdhWebSocketServer ...@@ -727,9 +808,7 @@ public class GdhWebSocketServer
i += 4; i += 4;
int nameSize = ((value[i] & 0xFF) << 0) + ((value[i+1] & 0xFF) << 8); int nameSize = ((value[i] & 0xFF) << 0) + ((value[i+1] & 0xFF) << 8);
i += 2; i += 2;
System.out.println( "val: " + val + "nameSize: " + nameSize);
String attrName = new String( value, i, nameSize); String attrName = new String( value, i, nameSize);
System.out.println( "attrName : " + attrName);
PwrtStatus ret = gdh.setObjectInfo( attrName, bvalue); PwrtStatus ret = gdh.setObjectInfo( attrName, bvalue);
int sts = ret.getSts(); int sts = ret.getSts();
...@@ -764,9 +843,7 @@ public class GdhWebSocketServer ...@@ -764,9 +843,7 @@ public class GdhWebSocketServer
i += 4; i += 4;
int nameSize = ((value[i] & 0xFF) << 0) + ((value[i+1] & 0xFF) << 8); int nameSize = ((value[i] & 0xFF) << 0) + ((value[i+1] & 0xFF) << 8);
i += 2; i += 2;
System.out.println( "val: " + ivalue + "nameSize: " + nameSize);
String attrName = new String( value, i, nameSize); String attrName = new String( value, i, nameSize);
System.out.println( "attrName : " + attrName);
PwrtStatus ret = gdh.setObjectInfo( attrName, ivalue); PwrtStatus ret = gdh.setObjectInfo( attrName, ivalue);
int sts = ret.getSts(); int sts = ret.getSts();
...@@ -801,9 +878,7 @@ public class GdhWebSocketServer ...@@ -801,9 +878,7 @@ public class GdhWebSocketServer
i += 4; i += 4;
int nameSize = ((value[i] & 0xFF) << 0) + ((value[i+1] & 0xFF) << 8); int nameSize = ((value[i] & 0xFF) << 0) + ((value[i+1] & 0xFF) << 8);
i += 2; i += 2;
System.out.println( "val: " + fvalue + " nameSize: " + nameSize);
String attrName = new String( value, i, nameSize); String attrName = new String( value, i, nameSize);
System.out.println( "attrName : " + attrName);
PwrtStatus ret = gdh.setObjectInfo( attrName, fvalue); PwrtStatus ret = gdh.setObjectInfo( attrName, fvalue);
int sts = ret.getSts(); int sts = ret.getSts();
...@@ -842,9 +917,7 @@ public class GdhWebSocketServer ...@@ -842,9 +917,7 @@ public class GdhWebSocketServer
int nameSize = ((value[i] & 0xFF) << 0) + ((value[i+1] & 0xFF) << 8); int nameSize = ((value[i] & 0xFF) << 0) + ((value[i+1] & 0xFF) << 8);
i += 2; i += 2;
System.out.println( "val: " + val + "nameSize: " + nameSize);
String attrName = new String( value, i, nameSize); String attrName = new String( value, i, nameSize);
System.out.println( "attrName : " + attrName);
PwrtStatus ret = gdh.setObjectInfo( attrName, val); PwrtStatus ret = gdh.setObjectInfo( attrName, val);
int sts = ret.getSts(); int sts = ret.getSts();
...@@ -878,7 +951,6 @@ public class GdhWebSocketServer ...@@ -878,7 +951,6 @@ public class GdhWebSocketServer
int nameSize = ((value[i] & 0xFF) << 0) + ((value[i+1] & 0xFF) << 8); int nameSize = ((value[i] & 0xFF) << 0) + ((value[i+1] & 0xFF) << 8);
i += 2; i += 2;
String attrName = new String( value, i, nameSize); String attrName = new String( value, i, nameSize);
System.out.println( "attrName : " + attrName);
PwrtStatus ret = gdh.toggleObjectInfo( attrName); PwrtStatus ret = gdh.toggleObjectInfo( attrName);
int sts = ret.getSts(); int sts = ret.getSts();
...@@ -908,6 +980,7 @@ public class GdhWebSocketServer ...@@ -908,6 +980,7 @@ public class GdhWebSocketServer
break; break;
case REF_OBJECT_INFO: case REF_OBJECT_INFO:
try { try {
int sts;
int i = 6; int i = 6;
int refId = ((value[i] & 0xFF) << 0) + ((value[i+1] & 0xFF) << 8) + ((value[i+2] & 0xFF) << 16) + ((value[i+3] & 0xFF) << 24); int refId = ((value[i] & 0xFF) << 0) + ((value[i+1] & 0xFF) << 8) + ((value[i+2] & 0xFF) << 16) + ((value[i+3] & 0xFF) << 24);
i += 4; i += 4;
...@@ -915,22 +988,23 @@ public class GdhWebSocketServer ...@@ -915,22 +988,23 @@ public class GdhWebSocketServer
i += 4; i += 4;
int nameSize = ((value[i] & 0xFF) << 0) + ((value[i+1] & 0xFF) << 8) + ((value[i+2] & 0xFF) << 16) + ((value[i+3] & 0xFF) << 24); int nameSize = ((value[i] & 0xFF) << 0) + ((value[i+1] & 0xFF) << 8) + ((value[i+2] & 0xFF) << 16) + ((value[i+3] & 0xFF) << 24);
i += 4; i += 4;
System.out.println( "nameSize: " + nameSize);
String attrName = new String( value, i, nameSize); String attrName = new String( value, i, nameSize);
System.out.println( "attrName : " + attrName + " " + threadNumber + " " + refId); attrName = checkAttrName( attrName);
if ( attrName != null) {
Sub ret = this.refObjectInfo(attrName, threadNumber, refId, elements); Sub ret = this.refObjectInfo(attrName, threadNumber, refId, elements);
System.out.println( "ret.sts " + ret.getSts() + " sub.subscriptionsIndex " + ret.subscriptionsIndex);
if ( ret.oddSts()) if ( ret.oddSts())
thSub.add(ret); thSub.add(ret);
int sts = ret.getSts(); sts = ret.getSts();
// if ( debug) if ( debug)
System.out.println( "refObjectInfo: " + id + " refId " + refId + " subidx " + ret.subscriptionsIndex + " " + attrName + " sts: " + ret.getSts() + " type " + ret.typeId); System.out.println( "refObjectInfo: " + id + " refId " + refId + " subidx " + ret.subscriptionsIndex + " " + attrName + " sts: " + ret.getSts() + " type " + ret.typeId);
}
i += nameSize; i += nameSize;
for ( int k = 0; k < thSub.size(); k++) { for ( int k = 0; k < thSub.size(); k++) {
if ( thSub.elementAt(k) == null) if ( thSub.elementAt(k) == null)
continue; continue;
if ( debug)
System.out.println( "thSub rcv " + k + " subidx " + ((Sub)thSub.elementAt(k)).subscriptionsIndex + " thSub " + thSub.elementAt(k)); System.out.println( "thSub rcv " + k + " subidx " + ((Sub)thSub.elementAt(k)).subscriptionsIndex + " thSub " + thSub.elementAt(k));
} }
...@@ -980,7 +1054,6 @@ public class GdhWebSocketServer ...@@ -980,7 +1054,6 @@ public class GdhWebSocketServer
if ( !found) if ( !found)
break; break;
System.out.println("UnrefObjectInfo: " + subId + " refId: " + tsub.refid.rix);
PwrtStatus rsts = this.unrefObjectInfo( tsub.subId, threadNumber); PwrtStatus rsts = this.unrefObjectInfo( tsub.subId, threadNumber);
thSub.set( idx, null); thSub.set( idx, null);
...@@ -1011,6 +1084,7 @@ public class GdhWebSocketServer ...@@ -1011,6 +1084,7 @@ public class GdhWebSocketServer
break; break;
case REF_OBJECT_INFO_LIST: case REF_OBJECT_INFO_LIST:
try { try {
int sts;
int i = 6; int i = 6;
int subSize = ((value[i] & 0xFF) << 0) + ((value[i+1] & 0xFF) << 8) + ((value[i+2] & 0xFF) << 16) + ((value[i+3] & 0xFF) << 24); int subSize = ((value[i] & 0xFF) << 0) + ((value[i+1] & 0xFF) << 8) + ((value[i+2] & 0xFF) << 16) + ((value[i+3] & 0xFF) << 24);
i += 4; i += 4;
...@@ -1021,23 +1095,24 @@ public class GdhWebSocketServer ...@@ -1021,23 +1095,24 @@ public class GdhWebSocketServer
i += 4; i += 4;
int nameSize = ((value[i] & 0xFF) << 0) + ((value[i+1] & 0xFF) << 8) + ((value[i+2] & 0xFF) << 16) + ((value[i+3] & 0xFF) << 24); int nameSize = ((value[i] & 0xFF) << 0) + ((value[i+1] & 0xFF) << 8) + ((value[i+2] & 0xFF) << 16) + ((value[i+3] & 0xFF) << 24);
i += 4; i += 4;
System.out.println( "nameSize: " + nameSize);
String attrName = new String( value, i, nameSize); String attrName = new String( value, i, nameSize);
System.out.println( "attrName : " + attrName + " " + threadNumber + " " + refId); attrName = checkAttrName( attrName);
if ( attrName != null) {
Sub ret = this.refObjectInfo(attrName, threadNumber, refId, elements); Sub ret = this.refObjectInfo(attrName, threadNumber, refId, elements);
System.out.println( "ret.sts " + ret.getSts() + " sub.subscriptionsIndex " + ret.subscriptionsIndex);
thSub.add(ret); thSub.add(ret);
System.out.println( " sub " + ret.subscriptionsIndex + " thSub " + ((Sub)thSub.elementAt(j)).subscriptionsIndex + " sub " + ret + " thSub " + thSub.elementAt(j));
int sts = ret.getSts(); sts = ret.getSts();
// if ( debug) if ( debug)
System.out.println( "refObjectInfoList: " + id + " refId " + refId + " subidx " + ret.subscriptionsIndex + " " + attrName + " sts: " + ret.getSts() + " type " + ret.typeId); System.out.println( "refObjectInfoList: " + id + " refId " + refId + " subidx " + ret.subscriptionsIndex + " " + attrName + " sts: " + ret.getSts() + " type " + ret.typeId);
}
i += nameSize; i += nameSize;
} }
if ( debug)
for ( int k = 0; k < thSub.size(); k++) for ( int k = 0; k < thSub.size(); k++)
System.out.println( "thSub rcv " + k + " subidx " + ((Sub)thSub.elementAt(k)).subscriptionsIndex + " thSub " + thSub.elementAt(k)); System.out.println( "thSub rcv " + k + " subidx " + ((Sub)thSub.elementAt(k)).subscriptionsIndex + " thSub " + thSub.elementAt(k));
int sts = 111; sts = 111;
byte[] msg = new byte[11]; byte[] msg = new byte[11];
msg[0] = (byte)130; msg[0] = (byte)130;
msg[1] = 9; msg[1] = 9;
...@@ -1073,11 +1148,14 @@ public class GdhWebSocketServer ...@@ -1073,11 +1148,14 @@ public class GdhWebSocketServer
continue; continue;
switch( asub.typeId) { switch( asub.typeId) {
case Pwr.eType_Boolean: case Pwr.eType_Boolean:
if ( asub.elements <= 1)
refsize += 8 + 1; refsize += 8 + 1;
else
refsize += 8 + asub.elements * 1;
cnt++; cnt++;
break; break;
case Pwr.eType_Float32: case Pwr.eType_Float32:
if ( asub.elements < 1) if ( asub.elements <= 1)
refsize += 8 + 4; refsize += 8 + 4;
else else
refsize += 8 + asub.elements * 4; refsize += 8 + asub.elements * 4;
...@@ -1090,9 +1168,14 @@ public class GdhWebSocketServer ...@@ -1090,9 +1168,14 @@ public class GdhWebSocketServer
case Pwr.eType_UInt16: case Pwr.eType_UInt16:
case Pwr.eType_UInt32: case Pwr.eType_UInt32:
case Pwr.eType_Status: case Pwr.eType_Status:
case Pwr.eType_NetStatus:
case Pwr.eType_Mask: case Pwr.eType_Mask:
case Pwr.eType_Enum: case Pwr.eType_Enum:
case graph_eType_Bit:
if ( asub.elements <= 1)
refsize += 8 + 4; refsize += 8 + 4;
else
refsize += 8 + asub.elements * 4;
cnt++; cnt++;
break; break;
case Pwr.eType_String: case Pwr.eType_String:
...@@ -1100,15 +1183,27 @@ public class GdhWebSocketServer ...@@ -1100,15 +1183,27 @@ public class GdhWebSocketServer
case Pwr.eType_DeltaTime: case Pwr.eType_DeltaTime:
case Pwr.eType_AttrRef: case Pwr.eType_AttrRef:
case Pwr.eType_Objid: case Pwr.eType_Objid:
if ( asub.elements <= 1) {
refsize += 8 + 2; refsize += 8 + 2;
String svalue = gdh.getObjectRefInfoString(asub.id, asub.typeId); String svalue = gdh.getObjectRefInfoString(asub.id, asub.typeId);
refsize += svalue.length(); refsize += svalue.length();
}
else {
refsize += 8;
String[] svalue = gdh.getObjectRefInfoStringArray(asub.id, asub.typeId,
asub.size, asub.elements);
for ( int l = 0; l < asub.elements; l++) {
if ( l < svalue.length)
refsize += 2 + svalue[l].length();
else
refsize += 2;
}
}
cnt++; cnt++;
break; break;
default: default:
continue; continue;
} }
System.out.println("GetAll " + cnt + " " + refsize);
} }
...@@ -1153,18 +1248,33 @@ public class GdhWebSocketServer ...@@ -1153,18 +1248,33 @@ public class GdhWebSocketServer
j += 4; j += 4;
for ( int i = 0; i < thSub.size(); i++) { for ( int i = 0; i < thSub.size(); i++) {
Sub asub = (Sub)thSub.elementAt(i); Sub asub = (Sub)thSub.elementAt(i);
if ( asub == null) if ( asub == null || asub.subscriptionsIndex == -1)
continue; continue;
switch( asub.typeId) { switch( asub.typeId) {
case Pwr.eType_Boolean: case Pwr.eType_Boolean:
bb.putInt( j, asub.subscriptionsIndex); bb.putInt( j, asub.subscriptionsIndex);
j += 4; j += 4;
if ( asub.elements <= 1) {
bb.putInt( j, 1); bb.putInt( j, 1);
j += 4; j += 4;
boolean bvalue = gdh.getObjectRefInfoBoolean(asub.id); boolean bvalue = gdh.getObjectRefInfoBoolean(asub.id);
bb.put( j, bvalue ? (byte)1 : (byte)0); bb.put( j, bvalue ? (byte)1 : (byte)0);
j += 1; j += 1;
if ( debug)
System.out.println( i + " Idx " + asub.subscriptionsIndex + " Value: " + bvalue + " Type " + asub.typeId + " " + (refsize) + " " + (j-jstart)); System.out.println( i + " Idx " + asub.subscriptionsIndex + " Value: " + bvalue + " Type " + asub.typeId + " " + (refsize) + " " + (j-jstart));
}
else {
bb.putInt( j, asub.elements);
j += 4;
boolean[] bvalue = gdh.getObjectRefInfoBooleanArray(asub.id, asub.elements);
for ( int k = 0; k < asub.elements; k++) {
if ( k < bvalue.length)
bb.put( j, bvalue[k] ? (byte)1 : (byte)0);
else
bb.put( j, (byte)0);
j += 1;
}
}
break; break;
case Pwr.eType_Float32: case Pwr.eType_Float32:
bb.putInt( j, asub.subscriptionsIndex); bb.putInt( j, asub.subscriptionsIndex);
...@@ -1172,9 +1282,9 @@ public class GdhWebSocketServer ...@@ -1172,9 +1282,9 @@ public class GdhWebSocketServer
if ( asub.elements <= 1) { if ( asub.elements <= 1) {
bb.putInt( j, 4); bb.putInt( j, 4);
j += 4; j += 4;
float fvalue = gdh.getObjectRefInfoFloat(asub.id); float fvalue = gdh.getObjectRefInfoFloat(asub.id); bb.putFloat( j, fvalue);
bb.putFloat( j, fvalue);
j += 4; j += 4;
if ( debug)
System.out.println( i + " Idx " + asub.subscriptionsIndex + " Value: " + fvalue + " Type " + asub.typeId + " " + (refsize) + " " + (j-jstart)); System.out.println( i + " Idx " + asub.subscriptionsIndex + " Value: " + fvalue + " Type " + asub.typeId + " " + (refsize) + " " + (j-jstart));
} }
else { else {
...@@ -1188,6 +1298,7 @@ public class GdhWebSocketServer ...@@ -1188,6 +1298,7 @@ public class GdhWebSocketServer
bb.putFloat( j, 0F); bb.putFloat( j, 0F);
j += 4; j += 4;
} }
if ( debug)
System.out.println( i + " Idx " + asub.subscriptionsIndex + " Value: " + fvalue[0] + " Type " + asub.typeId + " " + asub.elements + " " + (refsize) + " " + (j-jstart)); System.out.println( i + " Idx " + asub.subscriptionsIndex + " Value: " + fvalue[0] + " Type " + asub.typeId + " " + asub.elements + " " + (refsize) + " " + (j-jstart));
} }
break; break;
...@@ -1198,17 +1309,33 @@ public class GdhWebSocketServer ...@@ -1198,17 +1309,33 @@ public class GdhWebSocketServer
case Pwr.eType_UInt16: case Pwr.eType_UInt16:
case Pwr.eType_UInt32: case Pwr.eType_UInt32:
case Pwr.eType_Status: case Pwr.eType_Status:
case Pwr.eType_NetStatus:
case Pwr.eType_Mask: case Pwr.eType_Mask:
case Pwr.eType_Enum: case Pwr.eType_Enum:
case graph_eType_Bit:
bb.putInt( j, asub.subscriptionsIndex); bb.putInt( j, asub.subscriptionsIndex);
j += 4; j += 4;
if ( asub.elements <= 1) {
bb.putInt( j, 4); bb.putInt( j, 4);
j += 4; j += 4;
System.out.println( "getObjectRefInfoInt " + asub.id);
int ivalue = gdh.getObjectRefInfoInt(asub.id); int ivalue = gdh.getObjectRefInfoInt(asub.id);
bb.putInt( j, ivalue); bb.putInt( j, ivalue);
j += 4; j += 4;
if ( debug)
System.out.println( i + " Idx " + asub.subscriptionsIndex + " Value: " + ivalue + " Type " + asub.typeId + " " + (refsize) + " " + (j-jstart)); System.out.println( i + " Idx " + asub.subscriptionsIndex + " Value: " + ivalue + " Type " + asub.typeId + " " + (refsize) + " " + (j-jstart));
}
else {
bb.putInt( j, 4 * asub.elements);
j += 4;
int[] ivalue = gdh.getObjectRefInfoIntArray(asub.id, asub.elements);
for ( int k = 0; k < asub.elements; k++) {
if ( k < ivalue.length)
bb.putInt( j, ivalue[i]);
else
bb.putInt( j, 0);
j += 4;
}
}
break; break;
case Pwr.eType_String: case Pwr.eType_String:
case Pwr.eType_Time: case Pwr.eType_Time:
...@@ -1217,6 +1344,7 @@ public class GdhWebSocketServer ...@@ -1217,6 +1344,7 @@ public class GdhWebSocketServer
case Pwr.eType_Objid: case Pwr.eType_Objid:
bb.putInt( j, asub.subscriptionsIndex); bb.putInt( j, asub.subscriptionsIndex);
j += 4; j += 4;
if ( asub.elements <= 1) {
String svalue = gdh.getObjectRefInfoString(asub.id, asub.typeId); String svalue = gdh.getObjectRefInfoString(asub.id, asub.typeId);
bb.putInt( j, 2 + svalue.length()); bb.putInt( j, 2 + svalue.length());
j += 4; j += 4;
...@@ -1225,7 +1353,36 @@ public class GdhWebSocketServer ...@@ -1225,7 +1353,36 @@ public class GdhWebSocketServer
for ( int k = 0; k < svalue.length(); k++) { for ( int k = 0; k < svalue.length(); k++) {
bb.put( j++, (byte)svalue.charAt(k)); bb.put( j++, (byte)svalue.charAt(k));
} }
if ( debug)
System.out.println( i + " Idx " + asub.subscriptionsIndex + " Value: " + svalue + " Type " + asub.typeId + " " + (refsize) + " " + (j-jstart)); System.out.println( i + " Idx " + asub.subscriptionsIndex + " Value: " + svalue + " Type " + asub.typeId + " " + (refsize) + " " + (j-jstart));
}
else {
String[] svalue = gdh.getObjectRefInfoStringArray(asub.id, asub.typeId,
asub.size, asub.elements);
int len = 0;
for ( int l = 0; l < asub.elements; l++) {
if ( l < svalue.length)
len += 2 + svalue[l].length();
else
len += 2;
}
bb.putInt( j, len);
j += 4;
for ( int l = 0; l < asub.elements; l++) {
if ( l < svalue.length) {
bb.putShort( j, (short)svalue[l].length());
j += 2;
for ( int k = 0; k < svalue[l].length(); k++) {
bb.put( j++, (byte)svalue[l].charAt(k));
}
}
else {
bb.putShort( j, (short)0);
len += 2;
}
}
}
break; break;
default: default:
System.out.println( "***" + i + " Idx " + asub.subscriptionsIndex + " Type " + asub.typeId + " " + (refsize) + " " + (j-jstart)); System.out.println( "***" + i + " Idx " + asub.subscriptionsIndex + " Type " + asub.typeId + " " + (refsize) + " " + (j-jstart));
...@@ -1391,7 +1548,7 @@ public class GdhWebSocketServer ...@@ -1391,7 +1548,7 @@ public class GdhWebSocketServer
i += 4; i += 4;
objid.oix = ((value[i] & 0xFF) << 0) + ((value[i+1] & 0xFF) << 8) + ((value[i+2] & 0xFF) << 16) + ((value[i+3] & 0xFF) << 24); objid.oix = ((value[i] & 0xFF) << 0) + ((value[i+1] & 0xFF) << 8) + ((value[i+2] & 0xFF) << 16) + ((value[i+3] & 0xFF) << 24);
i += 4; i += 4;
System.out.println("GetAllClassAttr " + classid + " " + objid.vid + " " + objid.oix);
Vector<CdhrObjAttr> v = gdh.getAllClassAttributes(classid, objid); Vector<CdhrObjAttr> v = gdh.getAllClassAttributes(classid, objid);
for ( int j = 0; j < v.size(); j++) { for ( int j = 0; j < v.size(); j++) {
CdhrObjAttr ve = v.get(j); CdhrObjAttr ve = v.get(j);
...@@ -1476,11 +1633,16 @@ public class GdhWebSocketServer ...@@ -1476,11 +1633,16 @@ public class GdhWebSocketServer
break; break;
} }
case GET_OBJECT: case GET_OBJECT:
case GET_OBJECT_FROM_AREF:
case GET_OBJECT_FROM_NAME: { case GET_OBJECT_FROM_NAME: {
try { try {
int sts = 1; int sts = 1;
boolean isAref = true;
PwrtObjid objid = new PwrtObjid( 0, 0); PwrtObjid objid = new PwrtObjid( 0, 0);
PwrtObjid retobjid = new PwrtObjid( 0, 0); PwrtObjid retobjid = new PwrtObjid( 0, 0);
PwrtAttrRef aref = null;
PwrtAttrRef retaref = null;
String param1 = "";
int i = 6; int i = 6;
int op = ((value[i] & 0xFF) << 0) + ((value[i+1] & 0xFF) << 8); int op = ((value[i] & 0xFF) << 0) + ((value[i+1] & 0xFF) << 8);
i += 2; i += 2;
...@@ -1489,6 +1651,25 @@ public class GdhWebSocketServer ...@@ -1489,6 +1651,25 @@ public class GdhWebSocketServer
i += 4; i += 4;
objid.oix = ((value[i] & 0xFF) << 0) + ((value[i+1] & 0xFF) << 8) + ((value[i+2] & 0xFF) << 16) + ((value[i+3] & 0xFF) << 24); objid.oix = ((value[i] & 0xFF) << 0) + ((value[i+1] & 0xFF) << 8) + ((value[i+2] & 0xFF) << 16) + ((value[i+3] & 0xFF) << 24);
i += 4; i += 4;
isAref = false;
System.out.println("GetObject1 " + sts);
}
else if ( value[0] == GET_OBJECT_FROM_AREF) {
objid.vid = ((value[i] & 0xFF) << 0) + ((value[i+1] & 0xFF) << 8) + ((value[i+2] & 0xFF) << 16) + ((value[i+3] & 0xFF) << 24);
i += 4;
objid.oix = ((value[i] & 0xFF) << 0) + ((value[i+1] & 0xFF) << 8) + ((value[i+2] & 0xFF) << 16) + ((value[i+3] & 0xFF) << 24);
i += 4;
aref = new PwrtAttrRef(objid);
aref.offset = ((value[i] & 0xFF) << 0) + ((value[i+1] & 0xFF) << 8) + ((value[i+2] & 0xFF) << 16) + ((value[i+3] & 0xFF) << 24);
i += 4;
aref.body = ((value[i] & 0xFF) << 0) + ((value[i+1] & 0xFF) << 8) + ((value[i+2] & 0xFF) << 16) + ((value[i+3] & 0xFF) << 24);
i += 4;
aref.size = ((value[i] & 0xFF) << 0) + ((value[i+1] & 0xFF) << 8) + ((value[i+2] & 0xFF) << 16) + ((value[i+3] & 0xFF) << 24);
i += 4;
aref.flags = ((value[i] & 0xFF) << 0) + ((value[i+1] & 0xFF) << 8) + ((value[i+2] & 0xFF) << 16) + ((value[i+3] & 0xFF) << 24);
i += 4;
isAref = true;
System.out.println("GetObject1 " + sts);
} }
else { else {
int nameSize = ((value[i] & 0xFF) << 0) + ((value[i+1] & 0xFF) << 8); int nameSize = ((value[i] & 0xFF) << 0) + ((value[i+1] & 0xFF) << 8);
...@@ -1496,14 +1677,15 @@ public class GdhWebSocketServer ...@@ -1496,14 +1677,15 @@ public class GdhWebSocketServer
String objName = new String( value, i, nameSize); String objName = new String( value, i, nameSize);
i += nameSize; i += nameSize;
CdhrObjid oret = gdh.nameToObjid(objName); CdhrAttrRef aret = gdh.nameToAttrRef(objName);
if ( oret.evenSts()) if ( aret.evenSts())
sts = oret.getSts(); sts = aret.getSts();
else { else {
objid = oret.objid; aref = aret.aref;
objid = aret.aref.objid;
} }
} }
System.out.println( "GET_OBJECT " + op +": " + objid.vid + " " + objid.oix); System.out.println("GetObject2 " + sts);
if ( (sts & 1) != 0) { if ( (sts & 1) != 0) {
switch ( op) { switch ( op) {
case GET_OP_METHOD_PLC: { case GET_OP_METHOD_PLC: {
...@@ -1514,27 +1696,88 @@ public class GdhWebSocketServer ...@@ -1514,27 +1696,88 @@ public class GdhWebSocketServer
break; break;
} }
if ( cdhrClassId.classId == Pwrb.cClass_plc) { if ( cdhrClassId.classId == Pwrb.cClass_plc) {
CdhrObjid cdhrObjid = (CdhrObjid)gdh.getChild(objid); CdhrObjid cdhrObjid = gdh.getChild(objid);
if ( cdhrObjid.evenSts()) { if ( cdhrObjid.evenSts()) {
sts = cdhrObjid.getSts(); sts = cdhrObjid.getSts();
System.out.println("sts2 " + sts); System.out.println("sts2 " + sts);
break; break;
} }
retobjid = cdhrObjid.objid; retobjid = cdhrObjid.objid;
isAref = false;
}
else if ( cdhrClassId.classId == Pwrb.cClass_windowplc ||
cdhrClassId.classId == Pwrb.cClass_windowcond ||
cdhrClassId.classId == Pwrb.cClass_windoworderact ||
cdhrClassId.classId == Pwrb.cClass_windowsubstep) {
retobjid = objid;
isAref = false;
} }
else { else {
retobjid.vid = objid.vid; // Check if parent is a plc window
retobjid.oix = objid.oix; CdhrObjid cdhrObjid = gdh.getParent(objid);
if ( cdhrObjid.evenSts()) {
sts = cdhrObjid.getSts();
break;
}
cdhrClassId = gdh.getObjectClass( cdhrObjid.objid);
if ( cdhrClassId.evenSts()) {
sts = cdhrClassId.getSts();
break;
}
if ( cdhrClassId.classId == Pwrb.cClass_windowplc ||
cdhrClassId.classId == Pwrb.cClass_windowcond ||
cdhrClassId.classId == Pwrb.cClass_windoworderact ||
cdhrClassId.classId == Pwrb.cClass_windowsubstep) {
retobjid = cdhrObjid.objid;
isAref = false;
param1 = gdh.objidToName( objid, Cdh.mName_object).str;
}
else {
// Check if any PlcConnect
String name;
if ( isAref)
name = gdh.attrRefToName( aref, Cdh.mName_pathStrict).str;
else
name = gdh.objidToName( objid, Cdh.mName_pathStrict).str;
name += ".PlcConnect";
CdhrString cstr = gdh.getObjectInfoString(name);
if ( cstr.evenSts()) {
sts = cstr.getSts();
break;
}
cdhrObjid = gdh.nameToObjid(cstr.str);
if ( cdhrObjid.evenSts()) {
sts = cdhrObjid.getSts();
break;
}
param1 = gdh.objidToName( cdhrObjid.objid, Cdh.mName_object).str;
cdhrObjid = gdh.getParent(cdhrObjid.objid);
if ( cdhrObjid.evenSts()) {
sts = cdhrObjid.getSts();
break;
}
retobjid = cdhrObjid.objid;
isAref = false;
}
} }
break; break;
} }
default: default:
if ( isAref)
retaref = aref;
else {
retobjid.vid = objid.vid; retobjid.vid = objid.vid;
retobjid.oix = objid.oix; retobjid.oix = objid.oix;
}
break; break;
} }
} }
System.out.println("sts3 " + sts);
String name = null; String name = null;
String fullName = null; String fullName = null;
...@@ -1542,12 +1785,36 @@ public class GdhWebSocketServer ...@@ -1542,12 +1785,36 @@ public class GdhWebSocketServer
String className = null; String className = null;
CdhrObjid cdhrObjId; CdhrObjid cdhrObjId;
int cid = 0; int cid = 0;
CdhrClassId cdhrClassId;
boolean hasChildren = false; boolean hasChildren = false;
String param1 = "";
System.out.println("GetObject3 " + sts);
if ( (sts & 1) != 0) { if ( (sts & 1) != 0) {
cdhrClassId = gdh.getObjectClass(retobjid); if ( isAref) {
CdhrTypeId cdhrTypeId = gdh.getAttrRefTid(aref);
if(cdhrTypeId.oddSts()) {
cid = cdhrTypeId.typeId;
CdhrObjid classObj = gdh.classIdToObjid(cid);
if (classObj.oddSts()) {
className = gdh.objidToName( classObj.objid, Cdh.mName_object).str;
fullName = gdh.attrRefToName( retaref, Cdh.mName_pathStrict).str;
name = gdh.attrRefToName( retaref, Cdh.mName_object).str;
CdhrString ret = gdh.getObjectInfoString(fullName + ".Description");
if (ret.oddSts())
description = ret.str;
else
description = "";
if (gdh.getChild(retaref.objid).oddSts()) {
hasChildren = true;
}
}
else
sts = classObj.getSts();
}
else
sts = cdhrTypeId.getSts();
}
else {
CdhrClassId cdhrClassId = gdh.getObjectClass(retobjid);
if(cdhrClassId.oddSts()) { if(cdhrClassId.oddSts()) {
cid = cdhrClassId.classId; cid = cdhrClassId.classId;
CdhrObjid classObj = gdh.classIdToObjid(cdhrClassId.classId); CdhrObjid classObj = gdh.classIdToObjid(cdhrClassId.classId);
...@@ -1564,18 +1831,19 @@ public class GdhWebSocketServer ...@@ -1564,18 +1831,19 @@ public class GdhWebSocketServer
hasChildren = true; hasChildren = true;
} }
} }
else else {
sts = classObj.getSts(); sts = classObj.getSts();
System.out.println("GetObject4 " + sts);
} }
else }
else {
sts = cdhrClassId.getSts(); sts = cdhrClassId.getSts();
System.out.println("GetObject5 " + sts);
System.out.println( "sts: " + sts + " name " + fullName + " class " + className + " descr " + description); }
}
if ( op == GET_OP_METHOD_OBJECTGRAPH && (sts & 1) != 0) { if ( op == GET_OP_METHOD_OBJECTGRAPH && (sts & 1) != 0) {
String suffix = ""; String suffix = "";
cdhrClassId = gdh.getObjectClass( retobjid);
cid = cdhrClassId.classId;
String path = System.getenv("pwrp_web") + "/"; String path = System.getenv("pwrp_web") + "/";
String pwgname; String pwgname;
while ( true) { while ( true) {
...@@ -1610,7 +1878,6 @@ public class GdhWebSocketServer ...@@ -1610,7 +1878,6 @@ public class GdhWebSocketServer
pwgname = sret.str.toLowerCase() + suffix; pwgname = sret.str.toLowerCase() + suffix;
File file = new File( path + pwgname + ".pwg"); File file = new File( path + pwgname + ".pwg");
System.out.println("Check file " + path + pwgname + ".pwg");
if ( file.exists()) { if ( file.exists()) {
param1 = pwgname; param1 = pwgname;
break; break;
...@@ -1625,7 +1892,91 @@ public class GdhWebSocketServer ...@@ -1625,7 +1892,91 @@ public class GdhWebSocketServer
cid = rcid.classId; cid = rcid.classId;
} }
} }
else if ( op == GET_OP_METHOD_GRAPH && (sts & 1) != 0) {
String attr = fullName + ".DefGraph";
PwrtObjid oid = objid;
while ( true) {
System.out.println("Method graph test " + attr);
CdhrString xttgraph = gdh.getObjectInfoString( attr);
if ( xttgraph.oddSts() && !xttgraph.str.equals("")) {
attr = xttgraph.str + ".Action";
CdhrString actionRet = gdh.getObjectInfoString( attr);
if ( actionRet.evenSts()) return;
param1 = actionRet.str;
String instance = null;
attr = xttgraph.str + ".Object[0]";
CdhrString instanceRet = gdh.getObjectInfoString( attr);
if ( instanceRet.oddSts() && !instanceRet.str.equals("")) {
// Instance found
instance = instanceRet.str;
fullName = instance;
retobjid.vid = 0;
retobjid.oix = 0;
name = "";
className = "";
description = "";
hasChildren = false;
}
else {
// No instance
retobjid.vid = 0;
retobjid.oix = 0;
name = "";
fullName = "";
className = "";
description = "";
hasChildren = false;
}
break;
}
CdhrObjid cdhrObjid = gdh.getParent(oid);
if ( cdhrObjid.evenSts()) {
sts = cdhrObjid.getSts();
break;
}
oid = cdhrObjid.objid;
CdhrString sret = gdh.objidToName( cdhrObjid.objid, Cdh.mName_pathStrict);
System.out.println("Parent sts " + sret.getSts());
if ( sret.evenSts()) {
sts = sret.getSts();
break;
}
System.out.println("Parent " + sret.str);
attr = sret.str + ".DefGraph";
}
} }
else if ( op == GET_OP_METHOD_HELPCLASS && (sts & 1) != 0) {
CdhrObjid cdhrObjid = gdh.classIdToObjid(cid);
if ( cdhrObjid.evenSts()) {
sts = cdhrObjid.getSts();
break;
}
CdhrString sret = gdh.objidToName( cdhrObjid.objid, Cdh.mName_volume);
String volname = sret.str.substring(0, sret.str.length()-1);
sret = gdh.objidToName( cdhrObjid.objid, Cdh.mName_object);
String classname = sret.str;
if ( classname.substring(0,1).equals("$"))
classname = classname.substring(1);
System.out.println("Help class " + volname + " " + classname);
if ( cdhrObjid.objid.vid < Cdh.cUserClassVolMin)
param1 = "/pwr_doc/en_us/orm/" + volname.toLowerCase() + "_" + classname.toLowerCase() + ".html";
else
param1 = "/pwrp_web/" + volname.toLowerCase() + "_" + classname.toLowerCase() + ".html";
System.out.println("File " + param1);
}
}
else
System.out.println("Get object " + sts);
int j; int j;
int refsize = 0; int refsize = 0;
if ( (sts & 1) != 0) { if ( (sts & 1) != 0) {
...@@ -1707,9 +2058,10 @@ public class GdhWebSocketServer ...@@ -1707,9 +2058,10 @@ public class GdhWebSocketServer
} }
out.write( msg); out.write( msg);
out.flush(); out.flush();
System.out.println("GetObject " + fullName);
} }
catch ( IOException e) { catch ( IOException e) {
System.out.println("getAllClassAttributes: IO exception"); System.out.println("getObject: IO exception");
} }
break; break;
} }
...@@ -1744,7 +2096,6 @@ public class GdhWebSocketServer ...@@ -1744,7 +2096,6 @@ public class GdhWebSocketServer
refsize = 0; refsize = 0;
} }
else { else {
System.out.println( "crr " + cdhrString.str);
switch ( cid) { switch ( cid) {
case Pwrb.cClass_Di: case Pwrb.cClass_Di:
...@@ -1777,7 +2128,6 @@ public class GdhWebSocketServer ...@@ -1777,7 +2128,6 @@ public class GdhWebSocketServer
ctype = new int[crrlen]; ctype = new int[crrlen];
for ( i = 0; i < crrlen; i++) { for ( i = 0; i < crrlen; i++) {
System.out.println("Token : " + tokens[i]);
String[] subtokens = tokens[i].substring(1).split("\\s+"); String[] subtokens = tokens[i].substring(1).split("\\s+");
name[i] = subtokens[0]; name[i] = subtokens[0];
className[i] = subtokens[1]; className[i] = subtokens[1];
...@@ -1792,10 +2142,10 @@ public class GdhWebSocketServer ...@@ -1792,10 +2142,10 @@ public class GdhWebSocketServer
if ( className[i].equals( "XttGraph")) if ( className[i].equals( "XttGraph"))
oret = gdh.nameToObjid(name[i]); oret = gdh.nameToObjid(name[i]);
else { else {
System.out.println("Cossref : " + name[i]);
int idx = name[i].lastIndexOf('-'); int idx = name[i].lastIndexOf('-');
if ( idx != -1) { if ( idx != -1) {
oret = gdh.nameToObjid(name[i].substring(0,idx)); oret = gdh.nameToObjid(name[i].substring(0,idx));
if ( debug)
System.out.println("pwrent " + name[i].substring(0,idx) + " " + oret.objid.vid + " " + oret.objid.oix); System.out.println("pwrent " + name[i].substring(0,idx) + " " + oret.objid.vid + " " + oret.objid.oix);
} }
else else
...@@ -1806,7 +2156,6 @@ public class GdhWebSocketServer ...@@ -1806,7 +2156,6 @@ public class GdhWebSocketServer
else { else {
oid[i] = new PwrtObjid(0,0); oid[i] = new PwrtObjid(0,0);
} }
System.out.println("oid " + oid[i].vid + " " + oid[i].oix);
} }
refsize = 2; // Number of elements refsize = 2; // Number of elements
...@@ -1905,7 +2254,6 @@ public class GdhWebSocketServer ...@@ -1905,7 +2254,6 @@ public class GdhWebSocketServer
CdhrObjid oret; CdhrObjid oret;
Vector<WebButton> v = new Vector<WebButton>(); Vector<WebButton> v = new Vector<WebButton>();
System.out.println("OpPlace \"" + opPlace + "\"");
if ( opPlace.isEmpty()) { if ( opPlace.isEmpty()) {
// Get first // Get first
oret = gdh.getClassList( Pwrb.cClass_OpPlaceWeb); oret = gdh.getClassList( Pwrb.cClass_OpPlaceWeb);
...@@ -1992,12 +2340,10 @@ public class GdhWebSocketServer ...@@ -1992,12 +2340,10 @@ public class GdhWebSocketServer
break; break;
} }
System.out.println("Child " + childName + " " + button.text + " " + button.name + " " + button.url);
} }
cdhrObjId = gdh.getNextSibling(cdhrObjId.objid); cdhrObjId = gdh.getNextSibling(cdhrObjId.objid);
} }
} }
System.out.println( "GetOpwindMenu " + v.size());
int j; int j;
int refsize = 0; int refsize = 0;
...@@ -2026,7 +2372,6 @@ public class GdhWebSocketServer ...@@ -2026,7 +2372,6 @@ public class GdhWebSocketServer
refsize += ve.url.length(); refsize += ve.url.length();
} }
} }
System.out.println("OpwinMenu refsize " + refsize);
byte[] msg; byte[] msg;
if ( refsize + 11 < 125) { if ( refsize + 11 < 125) {
msg = new byte[13 + refsize + 1]; // One extra byte needed for ByteBuffer ?? msg = new byte[13 + refsize + 1]; // One extra byte needed for ByteBuffer ??
...@@ -2103,7 +2448,6 @@ public class GdhWebSocketServer ...@@ -2103,7 +2448,6 @@ public class GdhWebSocketServer
bb.put( j, (byte)ve.url.charAt(k)); bb.put( j, (byte)ve.url.charAt(k));
j++; j++;
} }
System.out.println("Button " + ve.type + " " + ve.text.length() + " " + ve.name.length() + " " + ve.url.length() );
} }
} }
out.write( msg); out.write( msg);
...@@ -2170,6 +2514,267 @@ public class GdhWebSocketServer ...@@ -2170,6 +2514,267 @@ public class GdhWebSocketServer
} }
break; break;
case GET_MSG: {
try {
int i = 6;
int status = ((value[i] & 0xFF) << 0) + ((value[i+1] & 0xFF) << 8) + ((value[i+2] & 0xFF) << 16) + ((value[i+3] & 0xFF) << 24);
i += 4;
int j;
int refsize;
CdhrString ret = gdh.getMsgText(status);
int sts = ret.getSts();
if ( ret.oddSts())
refsize = 2 + ret.str.length();
else
refsize = 0;
byte[] msg;
if ( refsize + 13 < 125) {
msg = new byte[15 + refsize + 1]; // One extra byte needed for ByteBuffer ??
msg[0] = (byte)130;
msg[1] = (byte)(13 + refsize + 1);
j = 2;
}
else {
msg = new byte[17 + refsize + 1];
msg[0] = (byte)130;
msg[1] = (byte)126;
msg[2] = (byte)(((13 + refsize + 1) >> 8) & 0xFF);
msg[3] = (byte)((13 + refsize + 1) & 0xFF);
j = 4;
}
msg[j++] = GET_MSG;
msg[j++] = (byte)(id >> 24);
msg[j++] = (byte)((id >> 16) & 0xFF);
msg[j++] = (byte)((id >> 8) & 0xFF);
msg[j++] = (byte)(id & 0xFF);
msg[j++] = (byte)(sts >> 24);
msg[j++] = (byte)((sts >> 16) & 0xFF);
msg[j++] = (byte)((sts >> 8) & 0xFF);
msg[j++] = (byte)(sts & 0xFF);
if ( ret.oddSts()) {
ByteBuffer bb = ByteBuffer.wrap( msg);
bb.putShort( j, (short)ret.str.length());
j += 2;
for ( int k = 0; k < ret.str.length(); k++) {
bb.put( j++, (byte)ret.str.charAt(k));
}
}
out.write( msg);
out.flush();
}
catch(IOException e) {
System.out.println("getMsg: IO exception");
}
break;
}
case MH_SYNC: {
try {
int i = 6;
int syncIdx = ((value[i] & 0xFF) << 0) + ((value[i+1] & 0xFF) << 8) + ((value[i+2] & 0xFF) << 16) + ((value[i+3] & 0xFF) << 24);
i += 4;
int sts = 1;
Vector<MhrEvent> v = new Vector<MhrEvent>();
int j;
for ( j = 0; j < mhData.eventVec.size(); j++) {
if ( mhData.eventVec.get(j).syncIdx == syncIdx)
break;
}
for ( j--; j >= 0; j--)
v.add( mhData.eventVec.get(j));
int refsize = 0;
for ( j = v.size() - 1; j >= 0; j--) {
MhrEvent e = v.get(j);
System.out.println("Sync: " + j + " " + e.syncIdx + " " + e.eventText);
refsize += 2; // eventTime length
refsize += e.eventTime.length(); // eventTime
refsize += 2; // eventText length
refsize += e.eventText.length(); // eventText
refsize += 2; // eventName length
refsize += e.eventName.length(); // eventName
refsize += 4; // eventFlags
refsize += 4; // eventStatus
refsize += 4; // eventPrio
refsize += 4; // eventId.nix
refsize += 4; // eventId.idx
refsize += 2; // eventId.birthTime length
refsize += e.eventId.birthTime.length(); // eventId.birthTime
refsize += 4; // targetId.nix
refsize += 4; // targetId.idx
refsize += 2; // targetId.birthTime length
refsize += e.targetId.birthTime.length(); // targetId.birthTime
refsize += 4; // eventType
refsize += 4; // object.objid.vid
refsize += 4; // object.objid.oix
refsize += 4; // object.offset
refsize += 4; // object.body
refsize += 4; // object.size
refsize += 4; // object.flags
refsize += 4; // supObject.objid.vid
refsize += 4; // supObject.objid.oix
refsize += 4; // supObject.offset
refsize += 4; // supObject.body
refsize += 4; // supObject.size
refsize += 4; // supObject.flags
refsize += 2; // eventMoreText length
refsize += e.eventMoreText.length(); // eventMoreText
refsize += 4; // syncIdx
}
byte[] msg;
if ( refsize + 13 < 125) {
msg = new byte[15 + refsize + 1]; // One extra byte needed for ByteBuffer ??
msg[0] = (byte)130;
msg[1] = (byte)(13 + refsize + 1);
j = 2;
}
else {
msg = new byte[17 + refsize + 1];
msg[0] = (byte)130;
msg[1] = (byte)126;
msg[2] = (byte)(((13 + refsize + 1) >> 8) & 0xFF);
msg[3] = (byte)((13 + refsize + 1) & 0xFF);
j = 4;
}
msg[j++] = MH_SYNC;
msg[j++] = (byte)(id >> 24);
msg[j++] = (byte)((id >> 16) & 0xFF);
msg[j++] = (byte)((id >> 8) & 0xFF);
msg[j++] = (byte)(id & 0xFF);
msg[j++] = (byte)(sts >> 24);
msg[j++] = (byte)((sts >> 16) & 0xFF);
msg[j++] = (byte)((sts >> 8) & 0xFF);
msg[j++] = (byte)(sts & 0xFF);
ByteBuffer bb = ByteBuffer.wrap( msg);
bb.putInt( j, v.size());
j += 4;
for ( i = v.size() - 1; i >= 0; i--) {
MhrEvent e = v.get(i);
bb.putShort( j, (short)e.eventTime.length());
System.out.println("event " + e.syncIdx + " " + e.eventType + " " + e.eventPrio);
j += 2;
for ( int k = 0; k < e.eventTime.length(); k++)
bb.put( j++, (byte)e.eventTime.charAt(k));
bb.putShort( j, (short)e.eventText.length());
j += 2;
for ( int k = 0; k < e.eventText.length(); k++)
bb.put( j++, (byte)e.eventText.charAt(k));
bb.putShort( j, (short)e.eventName.length());
j += 2;
for ( int k = 0; k < e.eventName.length(); k++)
bb.put( j++, (byte)e.eventName.charAt(k));
bb.putInt( j, e.eventFlags);
j += 4;
bb.putInt( j, e.eventStatus);
j += 4;
bb.putInt( j, e.eventPrio);
j += 4;
bb.putInt( j, e.eventId.nix);
j += 4;
bb.putInt( j, e.eventId.idx);
j += 4;
bb.putShort( j, (short)e.eventId.birthTime.length());
j += 2;
for ( int k = 0; k < e.eventId.birthTime.length(); k++)
bb.put( j++, (byte)e.eventId.birthTime.charAt(k));
bb.putInt( j, e.targetId.nix);
j += 4;
bb.putInt( j, e.targetId.idx);
j += 4;
bb.putShort( j, (short)e.targetId.birthTime.length());
j += 2;
for ( int k = 0; k < e.targetId.birthTime.length(); k++)
bb.put( j++, (byte)e.targetId.birthTime.charAt(k));
bb.putInt( j, e.eventType);
j += 4;
bb.putInt( j, e.object.objid.vid);
j += 4;
bb.putInt( j, e.object.objid.oix);
j += 4;
bb.putInt( j, e.object.offset);
j += 4;
bb.putInt( j, e.object.body);
j += 4;
bb.putInt( j, e.object.size);
j += 4;
bb.putInt( j, e.object.flags);
j += 4;
bb.putInt( j, e.supObject.objid.vid);
j += 4;
bb.putInt( j, e.supObject.objid.oix);
j += 4;
bb.putInt( j, e.supObject.offset);
j += 4;
bb.putInt( j, e.supObject.body);
j += 4;
bb.putInt( j, e.supObject.size);
j += 4;
bb.putInt( j, e.supObject.flags);
j += 4;
bb.putShort( j, (short)e.eventMoreText.length());
j += 2;
for ( int k = 0; k < e.eventMoreText.length(); k++)
bb.put( j++, (byte)e.eventMoreText.charAt(k));
bb.putInt( j, e.syncIdx);
j += 4;
}
out.write( msg);
out.flush();
}
catch(IOException e) {
System.out.println("mhSync: IO exception");
}
break;
}
case MH_ACK: {
try {
MhrsEventId eid = new MhrsEventId(0,null,0);
int i = 6;
eid.nix = ((value[i] & 0xFF) << 0) + ((value[i+1] & 0xFF) << 8) + ((value[i+2] & 0xFF) << 16) + ((value[i+3] & 0xFF) << 24);
i += 4;
eid.idx = ((value[i] & 0xFF) << 0) + ((value[i+1] & 0xFF) << 8) + ((value[i+2] & 0xFF) << 16) + ((value[i+3] & 0xFF) << 24);
i += 4;
int len = ((value[i] & 0xFF) << 0) + ((value[i+1] & 0xFF) << 8);
i += 2;
eid.birthTime = new String( value, i, len);
i += len;
System.out.println("Ack: " + eid.nix + " " + eid.idx);
PwrtStatus psts = mh.outunitAck(eid);
int sts = psts.getSts();
byte[] msg;
msg = new byte[11]; // One extra byte needed for ByteBuffer ??
msg[0] = (byte)130;
msg[1] = (byte)(9);
msg[2] = MH_ACK;
msg[3] = (byte)(id >> 24);
msg[4] = (byte)((id >> 16) & 0xFF);
msg[5] = (byte)((id >> 8) & 0xFF);
msg[6] = (byte)(id & 0xFF);
msg[7] = (byte)(sts >> 24);
msg[8] = (byte)((sts >> 16) & 0xFF);
msg[9] = (byte)((sts >> 8) & 0xFF);
msg[10] = (byte)(sts & 0xFF);
out.write( msg);
out.flush();
}
catch(IOException e) {
System.out.println("mhAck: IO exception");
}
break;
}
default: default:
System.out.println("Unknown function code received: " + value[0]); System.out.println("Unknown function code received: " + value[0]);
} }
...@@ -2211,7 +2816,6 @@ public class GdhWebSocketServer ...@@ -2211,7 +2816,6 @@ public class GdhWebSocketServer
} }
GdhrRefObjectInfo ret = gdh.refObjectInfo(attrName); GdhrRefObjectInfo ret = gdh.refObjectInfo(attrName);
System.out.println("gdh.refObjectInfo " + attrName + " type " + ret.typeId);
if(ret.oddSts()) if(ret.oddSts())
{ {
sub = new SubElement(maxConnections, threadNumber); sub = new SubElement(maxConnections, threadNumber);
...@@ -2341,6 +2945,74 @@ public class GdhWebSocketServer ...@@ -2341,6 +2945,74 @@ public class GdhWebSocketServer
return (ArrayList)subscriptions.clone(); return (ArrayList)subscriptions.clone();
} }
public synchronized String checkAttrName( String name)
{
String str = name.trim();
int idx;
// Replace $node
for ( int i = 0; i < 4; i++) {
if ( (idx = str.indexOf("$node")) != -1) {
CdhrObjid cdhro = gdh.getNodeObject(0);
String nname = gdh.objidToName(cdhro.objid, Cdh.mName_pathStrict).str;
str = str.substring(0, idx) + nname + str.substring(idx+5);
}
else
break;
}
// Translate reference variable
for ( int i = 0; i < 4; i++) {
if ( (idx = str.indexOf("&(")) != -1) {
String iname = str.substring(idx+2);
int idx2 = iname.indexOf(')');
if ( idx2 != -1) {
String rest = iname.substring( idx2 + 1);
iname = iname.substring( 0, idx2);
CdhrString ret = gdh.getObjectInfoString( iname);
if ( ret.evenSts() || ret.str.equals(""))
return null;
str = str.substring( 0, idx) + ret.str + rest;
}
else
break;
}
else
break;
}
for ( int i = 0; i < 4; i++) {
// Remove attribute before
if ( (idx = str.indexOf(".<")) != -1) {
String rest = str.substring( idx + 2);
int idx2 = str.lastIndexOf( '.', idx - 2);
if ( idx2 != -1)
str = str.substring( 0, idx2) + rest;
else
break;
}
else
break;
}
for ( int i = 0; i < 4; i++) {
// Remove segment name before
if ( (idx = str.indexOf("-<")) != -1) {
String rest = str.substring( idx + 2);
int idx2 = str.lastIndexOf( '-', idx - 2);
if ( idx2 != -1)
str = str.substring( 0, idx2) + rest;
else
break;
}
else
break;
}
return str;
}
} }
} }
...@@ -251,13 +251,12 @@ public class Mh ...@@ -251,13 +251,12 @@ public class Mh
String targetId_birthTime, String targetId_birthTime,
int targetId_idx, int targetId_idx,
int eventType, int eventType,
PwrtObjid object) PwrtAttrRef object,
PwrtAttrRef supObject,
String moreText)
{ {
//System.out.println("Larm " + timeString + " " + messString + " " + nameString + " flags " + flags + " prio " + prio + " sts " +
//status + " nix " + eventId_nix + " birttime " + eventId_birthTime + " idx " + eventId_idx +
//" typ " + eventType);
//hantera det mottagna meddelandet //hantera det mottagna meddelandet
//System.out.println("messReceived " + eventType); System.out.println("messReceived " + eventType);
MhrEvent evItem = new MhrEvent(messString, MhrEvent evItem = new MhrEvent(messString,
nameString, nameString,
timeString, timeString,
...@@ -266,7 +265,7 @@ public class Mh ...@@ -266,7 +265,7 @@ public class Mh
status, status,
eventId_nix, eventId_birthTime, eventId_idx, eventId_nix, eventId_birthTime, eventId_idx,
targetId_nix, targetId_birthTime, targetId_idx, targetId_nix, targetId_birthTime, targetId_idx,
eventType, object); eventType, object, supObject, moreText);
lastMhrEvent = evItem; lastMhrEvent = evItem;
newAlarmArrived = true; newAlarmArrived = true;
......
...@@ -49,6 +49,7 @@ public class MhData ...@@ -49,6 +49,7 @@ public class MhData
public int maxNrOfEvents; public int maxNrOfEvents;
public Vector<MhrEvent> alarmVec; public Vector<MhrEvent> alarmVec;
public Vector<MhrEvent> eventVec; public Vector<MhrEvent> eventVec;
public int lastSyncIdx = 0;
public MhData(int maxNrOfAlarms, int maxNrOfEvents) public MhData(int maxNrOfAlarms, int maxNrOfEvents)
...@@ -119,6 +120,8 @@ public class MhData ...@@ -119,6 +120,8 @@ public class MhData
case Mh.mh_eEvent_UserAlarm3: case Mh.mh_eEvent_UserAlarm3:
case Mh.mh_eEvent_UserAlarm4: case Mh.mh_eEvent_UserAlarm4:
// Add to alarm list // Add to alarm list
lastSyncIdx++;
ev.syncIdx = lastSyncIdx;
this.addMessToVectorInSortedOrder(alarmVec, ev); this.addMessToVectorInSortedOrder(alarmVec, ev);
// Add copy to event list // Add copy to event list
this.addMessToVectorInSortedOrder(eventVec, ev.getCopy()); this.addMessToVectorInSortedOrder(eventVec, ev.getCopy());
...@@ -146,9 +149,20 @@ public class MhData ...@@ -146,9 +149,20 @@ public class MhData
if((ev.eventFlags & Mh.mh_mEventFlags_Return) != 0) if((ev.eventFlags & Mh.mh_mEventFlags_Return) != 0)
{ {
// Add copy to event list // Add copy to event list
lastSyncIdx++;
ev.syncIdx = lastSyncIdx;
this.addMessToVectorInSortedOrder(eventVec, ev.getCopy()); this.addMessToVectorInSortedOrder(eventVec, ev.getCopy());
} }
break; break;
case Mh.mh_eEvent_Block:
case Mh.mh_eEvent_Reblock:
case Mh.mh_eEvent_Cancel:
case Mh.mh_eEvent_Unblock:
// Add copy to event list
lastSyncIdx++;
ev.syncIdx = lastSyncIdx;
this.addMessToVectorInSortedOrder(eventVec, ev.getCopy());
break;
case Mh.mh_eEvent_Ack: case Mh.mh_eEvent_Ack:
for(int i = 0; i < alarmVec.size(); i++) for(int i = 0; i < alarmVec.size(); i++)
{ {
...@@ -169,6 +183,8 @@ public class MhData ...@@ -169,6 +183,8 @@ public class MhData
if((ev.eventFlags & Mh.mh_mEventFlags_Ack) != 0) if((ev.eventFlags & Mh.mh_mEventFlags_Ack) != 0)
{ {
// Add copy to event list // Add copy to event list
lastSyncIdx++;
ev.syncIdx = lastSyncIdx;
this.addMessToVectorInSortedOrder(eventVec, ev.getCopy()); this.addMessToVectorInSortedOrder(eventVec, ev.getCopy());
} }
break; break;
...@@ -177,6 +193,8 @@ public class MhData ...@@ -177,6 +193,8 @@ public class MhData
// Add to alarm list // Add to alarm list
if((ev.eventFlags & Mh.mh_mEventFlags_InfoWindow) != 0) if((ev.eventFlags & Mh.mh_mEventFlags_InfoWindow) != 0)
{ {
lastSyncIdx++;
ev.syncIdx = lastSyncIdx;
this.addMessToVectorInSortedOrder(alarmVec, ev); this.addMessToVectorInSortedOrder(alarmVec, ev);
} }
// Add copy to event list // Add copy to event list
......
...@@ -52,7 +52,10 @@ public class MhrEvent implements Serializable ...@@ -52,7 +52,10 @@ public class MhrEvent implements Serializable
public MhrsEventId eventId; public MhrsEventId eventId;
public MhrsEventId targetId; public MhrsEventId targetId;
public int eventType; public int eventType;
public PwrtObjid object; public PwrtAttrRef object;
public PwrtAttrRef supObject;
public String eventMoreText;
public int syncIdx;
public MhrEvent(String eventText, public MhrEvent(String eventText,
String eventName, String eventName,
...@@ -67,7 +70,9 @@ public class MhrEvent implements Serializable ...@@ -67,7 +70,9 @@ public class MhrEvent implements Serializable
String targetId_birthTime, String targetId_birthTime,
int targetId_idx, int targetId_idx,
int eventType, int eventType,
PwrtObjid object) PwrtAttrRef object,
PwrtAttrRef supObject,
String eventMoreText)
{ {
this.eventText = eventText; this.eventText = eventText;
this.eventName = eventName; this.eventName = eventName;
...@@ -79,10 +84,12 @@ public class MhrEvent implements Serializable ...@@ -79,10 +84,12 @@ public class MhrEvent implements Serializable
this.targetId = new MhrsEventId(targetId_nix, targetId_birthTime, targetId_idx); this.targetId = new MhrsEventId(targetId_nix, targetId_birthTime, targetId_idx);
this.eventType = eventType; this.eventType = eventType;
this.object = object; this.object = object;
this.supObject = supObject;
this.eventMoreText = eventMoreText;
} }
public MhrEvent getCopy() public MhrEvent getCopy()
{ {
return new MhrEvent(eventText, MhrEvent ev = new MhrEvent(eventText,
eventName, eventName,
eventTime, eventTime,
eventFlags, eventFlags,
...@@ -95,7 +102,11 @@ public class MhrEvent implements Serializable ...@@ -95,7 +102,11 @@ public class MhrEvent implements Serializable
targetId.birthTime, targetId.birthTime,
targetId.idx, targetId.idx,
eventType, eventType,
object); object,
supObject,
eventMoreText);
ev.syncIdx = syncIdx;
return ev;
} }
public String toString() public String toString()
{ {
......
...@@ -42,12 +42,12 @@ local_java_sources = \ ...@@ -42,12 +42,12 @@ local_java_sources = \
SubElement.java \ SubElement.java \
GdhServer.java \ GdhServer.java \
GdhServerMonitor.java \ GdhServerMonitor.java \
GdhWebSocketServer.java \
HistQuery.java \ HistQuery.java \
MhrsEventId.java \ MhrsEventId.java \
MhrEvent.java \ MhrEvent.java \
Mh.java \ Mh.java \
MhData.java \ MhData.java \
GdhWebSocketServer.java \
MhServer.java \ MhServer.java \
Hist.java \ Hist.java \
HistServer.java HistServer.java
......
<!DOCTYPE html>
<html>
<head>
<title>Alarm List</title>
<link rel="stylesheet" type="text/css" href="toolbar.css">
</head>
<body>
<div class="toolbar" role="toolbar">
<div id="toolitem1" tabindex="0" class="toolbar-item" role="button"><img src="toolbar_ack.png"><img>....</div>
<div id="toolitem2" tabindex="-1" class="toolbar-item" role="button"><img src="toolbar_navigator.png"><img></div>
<div id="toolitem3" tabindex="-1" class="toolbar-item" role="button"><img src="toolbar_plc.png"><img>....</div>
<div id="toolitem4" tabindex="-1" class="toolbar-item" role="button"><img src="toolbar_graph.png"><img></div>
<div id="toolitem5" tabindex="-1" class="toolbar-item" role="button"><img src="toolbar_objectgraph.png"><img></div>
<div id="toolitem6" tabindex="-1" class="toolbar-item" role="button"><img src="toolbar_navigator.png"><img></div>
<div id="toolitem7" tabindex="-1" class="toolbar-item" role="button"><img src="toolbar_plc.png"><img></div>
<div id="toolitem8" tabindex="-1" class="toolbar-item" role="button"><img src="toolbar_history.png"><img></div>
<div id="toolitem9" tabindex="-1" class="toolbar-item" role="button"><img src="toolbar_object.png"><img></div>
<div id="toolitem10" tabindex="-1" class="toolbar-item" role="button"><img src="toolbar_crossref.png"><img></div>
<div id="toolitem11" tabindex="-1" class="toolbar-item" role="button"><img src="toolbar_help.png"><img></div>
<div id="toolitem12" tabindex="-1" class="toolbar-item" role="button"><img src="toolbar_classhelp.png"><img></div>
</div>
<!-- <div style="height:300px;overflow:auto;"> -->
<canvas id="flowcanvas" width="1200" height="800"></canvas>
<script src=ev.js></script>
<!-- </div> -->
<hr>
<address><a href="mailto:claes@debian86.ssab.com"></a></address>
</body>
</html>
This source diff could not be displayed because it is too large. You can view the blob instead.
include $(pwre_dir_symbols)
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(hw_name)/$(type_name)_generic.mk
ifeq ($($(type_name)_generic_mk),)
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(type_name)_generic.mk
endif
ifeq ($($(type_name)_generic_mk),)
include $(pwre_kroot)/tools/bld/src/$(type_name)_generic.mk
endif
-include ../../special.mk
-include ../special.mk
-include special.mk
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -39,7 +39,7 @@ function JopCrypt() { ...@@ -39,7 +39,7 @@ function JopCrypt() {
0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C,
0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34,
0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C,
0x3D, 0x3E, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00 0x3D, 0x3E, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00,
]; ];
this.shifts2 = this.shifts2 =
...@@ -67,7 +67,7 @@ function JopCrypt() { ...@@ -67,7 +67,7 @@ function JopCrypt() {
0x00080020, 0x00080030, 0x20080020, 0x20080030, 0x00080020, 0x00080030, 0x20080020, 0x20080030,
0x00090020, 0x00090030, 0x20090020, 0x20090030, 0x00090020, 0x00090030, 0x20090020, 0x20090030,
0x00080820, 0x00080830, 0x20080820, 0x20080830, 0x00080820, 0x00080830, 0x20080820, 0x20080830,
0x00090820, 0x00090830, 0x20090820, 0x20090830 0x00090820, 0x00090830, 0x20090820, 0x20090830,
], ],
[ [
/* for C bits (numbered as per FIPS 46) 7 8 10 11 12 13 */ /* for C bits (numbered as per FIPS 46) 7 8 10 11 12 13 */
...@@ -86,7 +86,7 @@ function JopCrypt() { ...@@ -86,7 +86,7 @@ function JopCrypt() {
0x10000400, 0x12000400, 0x10002400, 0x12002400, 0x10000400, 0x12000400, 0x10002400, 0x12002400,
0x10200400, 0x12200400, 0x10202400, 0x12202400, 0x10200400, 0x12200400, 0x10202400, 0x12202400,
0x10000404, 0x12000404, 0x10002404, 0x12002404, 0x10000404, 0x12000404, 0x10002404, 0x12002404,
0x10200404, 0x12200404, 0x10202404, 0x12202404 0x10200404, 0x12200404, 0x10202404, 0x12202404,
], ],
[ [
/* for C bits (numbered as per FIPS 46) 14 15 16 17 19 20 */ /* for C bits (numbered as per FIPS 46) 14 15 16 17 19 20 */
...@@ -105,7 +105,7 @@ function JopCrypt() { ...@@ -105,7 +105,7 @@ function JopCrypt() {
0x08000200, 0x08000201, 0x08040200, 0x08040201, 0x08000200, 0x08000201, 0x08040200, 0x08040201,
0x09000200, 0x09000201, 0x09040200, 0x09040201, 0x09000200, 0x09000201, 0x09040200, 0x09040201,
0x08000202, 0x08000203, 0x08040202, 0x08040203, 0x08000202, 0x08000203, 0x08040202, 0x08040203,
0x09000202, 0x09000203, 0x09040202, 0x09040203 0x09000202, 0x09000203, 0x09040202, 0x09040203,
], ],
[ [
/* for C bits (numbered as per FIPS 46) 21 23 24 26 27 28 */ /* for C bits (numbered as per FIPS 46) 21 23 24 26 27 28 */
...@@ -124,7 +124,7 @@ function JopCrypt() { ...@@ -124,7 +124,7 @@ function JopCrypt() {
0x04020000, 0x04120000, 0x04020100, 0x04120100, 0x04020000, 0x04120000, 0x04020100, 0x04120100,
0x04020008, 0x04120008, 0x04020108, 0x04120108, 0x04020008, 0x04120008, 0x04020108, 0x04120108,
0x04021000, 0x04121000, 0x04021100, 0x04121100, 0x04021000, 0x04121000, 0x04021100, 0x04121100,
0x04021008, 0x04121008, 0x04021108, 0x04121108 0x04021008, 0x04121008, 0x04021108, 0x04121108,
], ],
[ [
/* for D bits (numbered as per FIPS 46) 1 2 3 4 5 6 */ /* for D bits (numbered as per FIPS 46) 1 2 3 4 5 6 */
...@@ -143,7 +143,7 @@ function JopCrypt() { ...@@ -143,7 +143,7 @@ function JopCrypt() {
0x00101000, 0x10101000, 0x00111000, 0x10111000, 0x00101000, 0x10101000, 0x00111000, 0x10111000,
0x00101004, 0x10101004, 0x00111004, 0x10111004, 0x00101004, 0x10101004, 0x00111004, 0x10111004,
0x20101000, 0x30101000, 0x20111000, 0x30111000, 0x20101000, 0x30101000, 0x20111000, 0x30111000,
0x20101004, 0x30101004, 0x20111004, 0x30111004 0x20101004, 0x30101004, 0x20111004, 0x30111004,
], ],
[ [
/* for D bits (numbered as per FIPS 46) 8 9 11 12 13 14 */ /* for D bits (numbered as per FIPS 46) 8 9 11 12 13 14 */
...@@ -162,7 +162,7 @@ function JopCrypt() { ...@@ -162,7 +162,7 @@ function JopCrypt() {
0x02000001, 0x0A000001, 0x02000009, 0x0A000009, 0x02000001, 0x0A000001, 0x02000009, 0x0A000009,
0x02000401, 0x0A000401, 0x02000409, 0x0A000409, 0x02000401, 0x0A000401, 0x02000409, 0x0A000409,
0x02020001, 0x0A020001, 0x02020009, 0x0A020009, 0x02020001, 0x0A020001, 0x02020009, 0x0A020009,
0x02020401, 0x0A020401, 0x02020409, 0x0A020409 0x02020401, 0x0A020401, 0x02020409, 0x0A020409,
], ],
[ [
/* for D bits (numbered as per FIPS 46) 16 17 18 19 20 21 */ /* for D bits (numbered as per FIPS 46) 16 17 18 19 20 21 */
...@@ -181,7 +181,7 @@ function JopCrypt() { ...@@ -181,7 +181,7 @@ function JopCrypt() {
0x00200200, 0x00200300, 0x00280200, 0x00280300, 0x00200200, 0x00200300, 0x00280200, 0x00280300,
0x01200200, 0x01200300, 0x01280200, 0x01280300, 0x01200200, 0x01200300, 0x01280200, 0x01280300,
0x00200210, 0x00200310, 0x00280210, 0x00280310, 0x00200210, 0x00200310, 0x00280210, 0x00280310,
0x01200210, 0x01200310, 0x01280210, 0x01280310 0x01200210, 0x01200310, 0x01280210, 0x01280310,
], ],
[ [
/* for D bits (numbered as per FIPS 46) 22 23 24 25 27 28 */ /* for D bits (numbered as per FIPS 46) 22 23 24 25 27 28 */
...@@ -200,8 +200,8 @@ function JopCrypt() { ...@@ -200,8 +200,8 @@ function JopCrypt() {
0x00000820, 0x04000820, 0x00040820, 0x04040820, 0x00000820, 0x04000820, 0x00040820, 0x04040820,
0x00000822, 0x04000822, 0x00040822, 0x04040822, 0x00000822, 0x04000822, 0x00040822, 0x04040822,
0x00002820, 0x04002820, 0x00042820, 0x04042820, 0x00002820, 0x04002820, 0x00042820, 0x04042820,
0x00002822, 0x04002822, 0x00042822, 0x04042822 0x00002822, 0x04002822, 0x00042822, 0x04042822,
] ],
]; ];
this.SPtrans = this.SPtrans =
...@@ -223,7 +223,7 @@ function JopCrypt() { ...@@ -223,7 +223,7 @@ function JopCrypt() {
0x80820200, 0x00020200, 0x00820000, 0x80800200, 0x80820200, 0x00020200, 0x00820000, 0x80800200,
0x00800000, 0x80000200, 0x80020000, 0x00000000, 0x00800000, 0x80000200, 0x80020000, 0x00000000,
0x00020000, 0x00800000, 0x80800200, 0x00820200, 0x00020000, 0x00800000, 0x80800200, 0x00820200,
0x80000000, 0x80820000, 0x00000200, 0x80020200 0x80000000, 0x80820000, 0x00000200, 0x80020200,
], ],
[ [
/* nibble 1 */ /* nibble 1 */
...@@ -242,7 +242,7 @@ function JopCrypt() { ...@@ -242,7 +242,7 @@ function JopCrypt() {
0x10042000, 0x00002000, 0x00000000, 0x10000004, 0x10042000, 0x00002000, 0x00000000, 0x10000004,
0x00000004, 0x10042004, 0x00042000, 0x10040000, 0x00000004, 0x10042004, 0x00042000, 0x10040000,
0x10040004, 0x00040000, 0x00002004, 0x10002000, 0x10040004, 0x00040000, 0x00002004, 0x10002000,
0x10002004, 0x00000004, 0x10040000, 0x00042000 0x10002004, 0x00000004, 0x10040000, 0x00042000,
], ],
[ [
/* nibble 2 */ /* nibble 2 */
...@@ -261,7 +261,7 @@ function JopCrypt() { ...@@ -261,7 +261,7 @@ function JopCrypt() {
0x40010040, 0x41000000, 0x01000000, 0x41010040, 0x40010040, 0x41000000, 0x01000000, 0x41010040,
0x00010000, 0x01000040, 0x41000040, 0x00010040, 0x00010000, 0x01000040, 0x41000040, 0x00010040,
0x01000040, 0x00000000, 0x41010000, 0x40000040, 0x01000040, 0x00000000, 0x41010000, 0x40000040,
0x41000000, 0x40010040, 0x00000040, 0x01010000 0x41000000, 0x40010040, 0x00000040, 0x01010000,
], ],
[ [
/* nibble 3 */ /* nibble 3 */
...@@ -280,7 +280,7 @@ function JopCrypt() { ...@@ -280,7 +280,7 @@ function JopCrypt() {
0x04000000, 0x04100402, 0x00100402, 0x00100000, 0x04000000, 0x04100402, 0x00100402, 0x00100000,
0x04100402, 0x00000002, 0x04000400, 0x00100402, 0x04100402, 0x00000002, 0x04000400, 0x00100402,
0x00100002, 0x00100400, 0x04100000, 0x04000402, 0x00100002, 0x00100400, 0x04100000, 0x04000402,
0x00000402, 0x04000000, 0x04000002, 0x04100400 0x00000402, 0x04000000, 0x04000002, 0x04100400,
], ],
[ [
/* nibble 4 */ /* nibble 4 */
...@@ -299,7 +299,7 @@ function JopCrypt() { ...@@ -299,7 +299,7 @@ function JopCrypt() {
0x02000108, 0x00000100, 0x00000000, 0x02004108, 0x02000108, 0x00000100, 0x00000000, 0x02004108,
0x02004008, 0x02004100, 0x00000108, 0x00004000, 0x02004008, 0x02004100, 0x00000108, 0x00004000,
0x00004100, 0x02004008, 0x02000100, 0x00000108, 0x00004100, 0x02004008, 0x02000100, 0x00000108,
0x00000008, 0x00004108, 0x02004000, 0x02000008 0x00000008, 0x00004108, 0x02004000, 0x02000008,
], ],
[ [
/* nibble 5 */ /* nibble 5 */
...@@ -318,7 +318,7 @@ function JopCrypt() { ...@@ -318,7 +318,7 @@ function JopCrypt() {
0x20080810, 0x00080800, 0x00080000, 0x20000810, 0x20080810, 0x00080800, 0x00080000, 0x20000810,
0x20000010, 0x20080000, 0x00080810, 0x00000000, 0x20000010, 0x20080000, 0x00080810, 0x00000000,
0x00000800, 0x20000010, 0x20000810, 0x20080800, 0x00000800, 0x20000010, 0x20000810, 0x20080800,
0x20080000, 0x00000810, 0x00000010, 0x20080010 0x20080000, 0x00000810, 0x00000010, 0x20080010,
], ],
[ [
/* nibble 6 */ /* nibble 6 */
...@@ -337,7 +337,7 @@ function JopCrypt() { ...@@ -337,7 +337,7 @@ function JopCrypt() {
0x00000000, 0x00400081, 0x00400080, 0x00001080, 0x00000000, 0x00400081, 0x00400080, 0x00001080,
0x00000081, 0x00001000, 0x00401081, 0x00400000, 0x00000081, 0x00001000, 0x00401081, 0x00400000,
0x00401080, 0x00000001, 0x00001001, 0x00401081, 0x00401080, 0x00000001, 0x00001001, 0x00401081,
0x00400001, 0x00401080, 0x00401000, 0x00001001 0x00400001, 0x00401080, 0x00401000, 0x00001001,
], ],
[ [
/* nibble 7 */ /* nibble 7 */
...@@ -372,31 +372,35 @@ function JopCrypt() { ...@@ -372,31 +372,35 @@ function JopCrypt() {
0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A
]; ];
this.byteToUnsigned = function (b) { this.byteToUnsigned = function(b)
{
var value = Math.floor(b); var value = Math.floor(b);
return (value >= 0 ? value : value + 256); return(value >= 0 ? value : value + 256);
}; }
this.fourBytesToInt = function (b, offset) { this.fourBytesToInt = function(b, offset)
{
var value; var value;
value = this.byteToUnsigned(b[offset++]); value = this.byteToUnsigned(b[offset++]);
value |= (this.byteToUnsigned(b[offset++]) << 8); value |= (this.byteToUnsigned(b[offset++]) << 8);
value |= (this.byteToUnsigned(b[offset++]) << 16); value |= (this.byteToUnsigned(b[offset++]) << 16);
value |= (this.byteToUnsigned(b[offset]) << 24); value |= (this.byteToUnsigned(b[offset++]) << 24);
return value; return value;
}; }
this.intToFourBytes = function (iValue, b, offset) { this.intToFourBytes = function(iValue, b, offset)
{
b[offset++] = ((iValue) & 0xff); b[offset++] = ((iValue) & 0xff);
b[offset++] = ((iValue >>> 8) & 0xff); b[offset++] = ((iValue >>> 8 ) & 0xff);
b[offset++] = ((iValue >>> 16) & 0xff); b[offset++] = ((iValue >>> 16) & 0xff);
b[offset] = ((iValue >>> 24) & 0xff); b[offset++] = ((iValue >>> 24) & 0xff);
}; }
this.PERM_OP = function (a, b, n, m, results) { this.PERM_OP = function(a, b, n, m, results)
{
var t; var t;
t = ((a >>> n) ^ b) & m; t = ((a >>> n) ^ b) & m;
...@@ -405,18 +409,19 @@ function JopCrypt() { ...@@ -405,18 +409,19 @@ function JopCrypt() {
results[0] = a; results[0] = a;
results[1] = b; results[1] = b;
}; }
this.HPERM_OP = function (a, n, m) { this.HPERM_OP = function(a, n, m)
{
var t; var t;
t = ((a << (16 - n)) ^ a) & m; t = ((a << (16 - n)) ^ a) & m;
a = a ^ t ^ (t >>> (16 - n)); a = a ^ t ^ (t >>> (16 - n));
return (a); return(a);
}; }
this.des_set_key = function (key) { this.des_set_key = function(key) {
var schedule = new Array(this.ITERATIONS * 2); var schedule = new Array(this.ITERATIONS * 2);
var c = this.fourBytesToInt(key, 0); var c = this.fourBytesToInt(key, 0);
...@@ -446,11 +451,13 @@ function JopCrypt() { ...@@ -446,11 +451,13 @@ function JopCrypt() {
var s, t; var s, t;
var j = 0; var j = 0;
for (var i = 0; i < this.ITERATIONS; i++) { for(var i = 0; i < this.ITERATIONS; i++) {
if (this.shifts2[i]) { if(this.shifts2[i]) {
c = (c >>> 2) | (c << 26); c = (c >>> 2) | (c << 26);
d = (d >>> 2) | (d << 26); d = (d >>> 2) | (d << 26);
} else { }
else
{
c = (c >>> 1) | (c << 27); c = (c >>> 1) | (c << 27);
d = (d >>> 1) | (d << 27); d = (d >>> 1) | (d << 27);
} }
...@@ -458,16 +465,16 @@ function JopCrypt() { ...@@ -458,16 +465,16 @@ function JopCrypt() {
c &= 0x0fffffff; c &= 0x0fffffff;
d &= 0x0fffffff; d &= 0x0fffffff;
s = this.skb[0][(c) & 0x3f] | s = this.skb[0][ (c ) & 0x3f ]|
this.skb[1][((c >>> 6) & 0x03) | ((c >>> 7) & 0x3c)] | this.skb[1][((c >>> 6) & 0x03) | ((c >>> 7) & 0x3c)]|
this.skb[2][((c >>> 13) & 0x0f) | ((c >>> 14) & 0x30)] | this.skb[2][((c >>> 13) & 0x0f) | ((c >>> 14) & 0x30)]|
this.skb[3][((c >>> 20) & 0x01) | ((c >>> 21) & 0x06) | this.skb[3][((c >>> 20) & 0x01) | ((c >>> 21) & 0x06) |
((c >>> 22) & 0x38)]; ((c >>> 22) & 0x38)];
t = this.skb[4][(d) & 0x3f] | t = this.skb[4][ (d ) & 0x3f ]|
this.skb[5][((d >>> 7) & 0x03) | ((d >>> 8) & 0x3c)] | this.skb[5][((d >>> 7) & 0x03) | ((d >>> 8) & 0x3c)]|
this.skb[6][(d >>> 15) & 0x3f] | this.skb[6][ (d >>>15) & 0x3f ]|
this.skb[7][((d >>> 21) & 0x0f) | ((d >>> 22) & 0x30)]; this.skb[7][((d >>>21) & 0x0f) | ((d >>> 22) & 0x30)];
schedule[j++] = ((t << 16) | (s & 0x0000ffff)) & 0xffffffff; schedule[j++] = ((t << 16) | (s & 0x0000ffff)) & 0xffffffff;
s = ((s >>> 16) | (t & 0xffff0000)); s = ((s >>> 16) | (t & 0xffff0000));
...@@ -476,9 +483,9 @@ function JopCrypt() { ...@@ -476,9 +483,9 @@ function JopCrypt() {
schedule[j++] = s & 0xffffffff; schedule[j++] = s & 0xffffffff;
} }
return schedule; return schedule;
}; }
this.D_ENCRYPT = function (L, R, S, E0, E1, s) { this.D_ENCRYPT = function( L, R, S, E0, E1, s) {
var t, u, v; var t, u, v;
v = R ^ (R >>> 16); v = R ^ (R >>> 16);
...@@ -488,25 +495,27 @@ function JopCrypt() { ...@@ -488,25 +495,27 @@ function JopCrypt() {
t = (v ^ (v << 16)) ^ R ^ s[S + 1]; t = (v ^ (v << 16)) ^ R ^ s[S + 1];
t = (t >>> 4) | (t << 28); t = (t >>> 4) | (t << 28);
L ^= this.SPtrans[1][(t) & 0x3f] | L ^= this.SPtrans[1][(t ) & 0x3f] |
this.SPtrans[3][(t >>> 8) & 0x3f] | this.SPtrans[3][(t >>> 8) & 0x3f] |
this.SPtrans[5][(t >>> 16) & 0x3f] | this.SPtrans[5][(t >>> 16) & 0x3f] |
this.SPtrans[7][(t >>> 24) & 0x3f] | this.SPtrans[7][(t >>> 24) & 0x3f] |
this.SPtrans[0][(u) & 0x3f] | this.SPtrans[0][(u ) & 0x3f] |
this.SPtrans[2][(u >>> 8) & 0x3f] | this.SPtrans[2][(u >>> 8) & 0x3f] |
this.SPtrans[4][(u >>> 16) & 0x3f] | this.SPtrans[4][(u >>> 16) & 0x3f] |
this.SPtrans[6][(u >>> 24) & 0x3f]; this.SPtrans[6][(u >>> 24) & 0x3f];
return L; return L;
}; }
this.body = function (schedule, Eswap0, Eswap1) { this.body = function(schedule, Eswap0, Eswap1) {
var left = 0; var left = 0;
var right = 0; var right = 0;
var t = 0; var t = 0;
for (var j = 0; j < 25; j++) { for(var j = 0; j < 25; j ++)
for (var i = 0; i < this.ITERATIONS * 2; i += 4) { {
for(var i = 0; i < this.ITERATIONS * 2; i += 4)
{
left = this.D_ENCRYPT(left, right, i, Eswap0, Eswap1, schedule); left = this.D_ENCRYPT(left, right, i, Eswap0, Eswap1, schedule);
right = this.D_ENCRYPT(right, left, i + 2, Eswap0, Eswap1, schedule); right = this.D_ENCRYPT(right, left, i + 2, Eswap0, Eswap1, schedule);
} }
...@@ -544,30 +553,30 @@ function JopCrypt() { ...@@ -544,30 +553,30 @@ function JopCrypt() {
out[0] = left; out[1] = right; out[0] = left; out[1] = right;
return (out); return(out);
}; }
this.crypt = function (salt, original) { this.crypt = function(salt, original) {
while (salt.length < 2) { while(salt.length < 2)
salt += "A"; salt += "A";
}
var buffer; var buffer;
var charZero = salt.charAt(0) + ''; var charZero = salt.charAt(0)+'';
var charOne = salt.charAt(1) + ''; var charOne = salt.charAt(1)+'';
var ccZ = charZero.charCodeAt(0); var ccZ = charZero.charCodeAt(0);
var ccO = charOne.charCodeAt(0); var ccO = charOne.charCodeAt(0);
console.log("charZero", charZero, "charOne", charOne); console.log( "charZero", charZero, "charOne", charOne);
buffer = charZero + charOne + " "; buffer = charZero + charOne + " ";
console.log("buffer \"" + buffer + "\""); console.log( "buffer \"" + buffer + "\"");
var Eswap0 = this.con_salt[ccZ]; var Eswap0 = this.con_salt[ccZ];
var Eswap1 = this.con_salt[ccO] << 4; var Eswap1 = this.con_salt[ccO] << 4;
var key = [0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0]; var key = new Array(0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0);
for (var i = 0; i < key.length && i < original.length; i++) { for(var i = 0; i < key.length && i < original.length; i ++)
{
var iChar = original.charCodeAt(i); var iChar = original.charCodeAt(i);
key[i] = iChar << 1; key[i] = iChar << 1;
...@@ -582,22 +591,24 @@ function JopCrypt() { ...@@ -582,22 +591,24 @@ function JopCrypt() {
this.intToFourBytes(out[1], b, 4); this.intToFourBytes(out[1], b, 4);
b[8] = 0; b[8] = 0;
for (var i = 2, y = 0, u = 0x80; i < 13; i++) { for(var i = 2, y = 0, u = 0x80; i < 13; i ++)
for (var j = 0, c = 0; j < 6; j++) { {
for(var j = 0, c = 0; j < 6; j ++)
{
c <<= 1; c <<= 1;
if ((b[y] & u) !== 0) { if((b[y] & u) != 0)
c |= 1; c |= 1;
}
u >>>= 1; u >>>= 1;
if (u === 0) { if(u == 0)
{
y++; y++;
u = 0x80; u = 0x80;
} }
buffer = buffer.substring(0, i) + String.fromCharCode(this.cov_2char[c]) + buffer = buffer.substring(0,i) + String.fromCharCode(this.cov_2char[c]) +
buffer.substring(i + 1, buffer.length); buffer.substring(i+1,buffer.length);
} }
} }
return buffer; return buffer;
...@@ -605,91 +616,92 @@ function JopCrypt() { ...@@ -605,91 +616,92 @@ function JopCrypt() {
} }
/** Crypt end **/ /** Crypt end **/
/** Pwr start **/ /** Start Pwr **/
function PwrtStatus(sts) { function PwrtStatus( sts)
{
this.sts = sts; this.sts = sts;
this.evenSts = function () { return (sts % 2 === 0); }; this.evenSts = function() { return (sts % 2 === 0);};
this.oddSts = function () { return (sts % 2 === 1); }; this.oddSts = function() { return (sts % 2 == 1);};
this.getSts = function () { return sts; }; this.getSts = function() { return sts;};
} }
var Pwr = { var Pwr = {
eType_Boolean: 98305, eType_Boolean : 98305,
eType_Float32: 98306, eType_Float32 : 98306,
eType_Float64: 98307, eType_Float64 : 98307,
eType_Char: 98308, eType_Char : 98308,
eType_Int8: 98309, eType_Int8 : 98309,
eType_Int16: 98310, eType_Int16 : 98310,
eType_Int32: 98311, eType_Int32 : 98311,
eType_UInt8: 98312, eType_UInt8 : 98312,
eType_UInt16: 98313, eType_UInt16 : 98313,
eType_UInt32: 98314, eType_UInt32 : 98314,
eType_Objid: 98315, eType_Objid : 98315,
eType_Buffer: 98316, eType_Buffer : 98316,
eType_String: 98317, eType_String : 98317,
eType_Enum: 98318, eType_Enum : 98318,
eType_Struct: 98319, eType_Struct : 98319,
eType_Mask: 98320, eType_Mask : 98320,
eType_Array: 98321, eType_Array : 98321,
eType_Time: 98322, eType_Time : 98322,
eType_Text: 98323, eType_Text : 98323,
eType_AttrRef: 98324, eType_AttrRef : 98324,
eType_UInt64: 98325, eType_UInt64 : 98325,
eType_Int64: 98326, eType_Int64 : 98326,
eType_ClassId: 98327, eType_ClassId : 98327,
eType_TypeId: 98328, eType_TypeId : 98328,
eType_VolumeId: 98329, eType_VolumeId : 98329,
eType_ObjectIx: 98330, eType_ObjectIx : 98330,
eType_RefId: 98331, eType_RefId : 98331,
eType_DeltaTime: 98332, eType_DeltaTime : 98332,
eType_Status: 98333, eType_Status : 98333,
eType_NetStatus: 98334, eType_NetStatus : 98334,
eType_CastId: 98335, eType_CastId : 98335,
eType_ProString: 98336, eType_ProString : 98336,
eType_DisableAttr: 98337, eType_DisableAttr : 98337,
eType_DataRef: 98338, eType_DataRef : 98338,
mPrv_RtRead: 1 << 0, mPrv_RtRead : 1 << 0,
mPrv_RtWrite: 1 << 1, mPrv_RtWrite : 1 << 1,
mPrv_System: 1 << 2, mPrv_System : 1 << 2,
mPrv_Maintenance: 1 << 3, mPrv_Maintenance : 1 << 3,
mPrv_Process: 1 << 4, mPrv_Process : 1 << 4,
mPrv_Instrument: 1 << 5, mPrv_Instrument : 1 << 5,
mPrv_Operator1: 1 << 6, mPrv_Operator1 : 1 << 6,
mPrv_Operator2: 1 << 7, mPrv_Operator2 : 1 << 7,
mPrv_Operator3: 1 << 8, mPrv_Operator3 : 1 << 8,
mPrv_Operator4: 1 << 9, mPrv_Operator4 : 1 << 9,
mPrv_Operator5: 1 << 10, mPrv_Operator5 : 1 << 10,
mPrv_Operator6: 1 << 11, mPrv_Operator6 : 1 << 11,
mPrv_Operator7: 1 << 12, mPrv_Operator7 : 1 << 12,
mPrv_Operator8: 1 << 13, mPrv_Operator8 : 1 << 13,
mPrv_Operator9: 1 << 14, mPrv_Operator9 : 1 << 14,
mPrv_Operator10: 1 << 15, mPrv_Operator10 : 1 << 15,
mPrv_RtEventsAck: 1 << 18, mPrv_RtEventsAck : 1 << 18,
mPrv_RtPlc: 1 << 19, mPrv_RtPlc : 1 << 19,
mPrv_RtNavigator: 1 << 20, mPrv_RtNavigator : 1 << 20,
mPrv_DevRead: 1 << 21, mPrv_DevRead : 1 << 21,
mPrv_DevPlc: 1 << 22, mPrv_DevPlc : 1 << 22,
mPrv_DevConfig: 1 << 23, mPrv_DevConfig : 1 << 23,
mPrv_DevClass: 1 << 24, mPrv_DevClass : 1 << 24,
mPrv_RtEventsBlock: 1 << 25, mPrv_RtEventsBlock : 1 << 25,
mPrv_Administrator: 1 << 26, mPrv_Administrator : 1 << 26,
mPrv_SevRead: 1 << 27, mPrv_SevRead : 1 << 27,
mPrv_SevAdmin: 1 << 28, mPrv_SevAdmin : 1 << 28,
mAccess_RtRead: 1 << 0, mAccess_RtRead : 1 << 0,
mAccess_RtWrite: 1 << 1, mAccess_RtWrite : 1 << 1,
mAccess_System: 1 << 2, mAccess_System : 1 << 2,
mAccess_Maintenance: 1 << 3, mAccess_Maintenance : 1 << 3,
mAccess_Process: 1 << 4, mAccess_Process : 1 << 4,
mAccess_Instrument: 1 << 5, mAccess_Instrument : 1 << 5,
mAccess_RtEventsBlock: 1 << 25, mAccess_RtEventsBlock : 1 << 25,
mAccess_RtEventsAck: 1 << 18, mAccess_RtEventsAck : 1 << 18,
mAccess_RtPlc: 1 << 19, mAccess_RtPlc : 1 << 19,
mAccess_RtNavigator: 1 << 20, mAccess_RtNavigator : 1 << 20,
mAccess_AllRt: 1 << 2 | mAccess_AllRt : 1 << 2 |
1 << 3 | 1 << 3 |
1 << 4 | 1 << 4 |
1 << 5 | 1 << 5 |
...@@ -709,7 +721,7 @@ var Pwr = { ...@@ -709,7 +721,7 @@ var Pwr = {
1 << 13 | 1 << 13 |
1 << 14 | 1 << 14 |
1 << 15, 1 << 15,
mAccess_AllOperators: 1 << 6 | mAccess_AllOperators : 1 << 6 |
1 << 7 | 1 << 7 |
1 << 8 | 1 << 8 |
1 << 9 | 1 << 9 |
...@@ -719,74 +731,94 @@ var Pwr = { ...@@ -719,74 +731,94 @@ var Pwr = {
1 << 13 | 1 << 13 |
1 << 14 | 1 << 14 |
1 << 15, 1 << 15,
mAccess_AllPwr: ~0, mAccess_AllPwr : ~0,
mAdef_pointer: 1, mAdef_pointer : 1,
mAdef_array: 2, mAdef_array : 2,
mAdef_backup: 4, mAdef_backup : 4,
mAdef_changelog: 8, mAdef_changelog : 8,
mAdef_state: 16, mAdef_state : 16,
mAdef_const: 32, mAdef_const : 32,
mAdef_rtvirtual: 64, mAdef_rtvirtual : 64,
mAdef_devbodyref: 128, mAdef_devbodyref : 128,
mAdef_dynamic: 256, mAdef_dynamic : 256,
mAdef_publicwrite: 512, mAdef_publicwrite : 512,
mAdef_noedit: 1024, mAdef_noedit : 1024,
mAdef_invisible: 2048, mAdef_invisible : 2048,
mAdef_refdirect: 4096, mAdef_refdirect : 4096,
mAdef_noinvert: 8192, mAdef_noinvert : 8192,
mAdef_noremove: 16384, mAdef_noremove : 16384,
mAdef_rtdbref: 32768, mAdef_rtdbref : 32768,
mAdef_private: 65536, mAdef_private : 65536,
mAdef_class: 131072, mAdef_class : 131072,
mAdef_superclass: 262144, mAdef_superclass : 262144,
mAdef_buffer: 524288, mAdef_buffer : 524288,
mAdef_nowbl: 1048576, mAdef_nowbl : 1048576,
mAdef_alwayswbl: 2097152, mAdef_alwayswbl : 2097152,
mAdef_disableattr: 4194304, mAdef_disableattr : 4194304,
mAdef_rthide: 8388608 mAdef_rthide : 8388608
}; };
var Pwrb = { var Pwrb = {
mXttMethodsFlagsMask_IsConfigured: 1, mXttMethodsFlagsMask_IsConfigured : 1,
mXttOpMethodsMask_OpenGraph: 1, mXttOpMethodsMask_OpenGraph : 1,
mXttOpMethodsMask_OpenObjectGraph: 2, mXttOpMethodsMask_OpenObjectGraph : 2,
mXttOpMethodsMask_OpenTrend: 4, mXttOpMethodsMask_OpenTrend : 4,
mXttOpMethodsMask_OpenHistory: 8, mXttOpMethodsMask_OpenHistory : 8,
mXttOpMethodsMask_OpenFast: 16, mXttOpMethodsMask_OpenFast : 16,
mXttOpMethodsMask_Camera: 32, mXttOpMethodsMask_Camera : 32,
mXttOpMethodsMask_HistEvent: 64, mXttOpMethodsMask_HistEvent : 64,
mXttOpMethodsMask_BlockEvents: 128, mXttOpMethodsMask_BlockEvents : 128,
mXttOpMethodsMask_Help: 256, mXttOpMethodsMask_Help : 256,
mXttOpMethodsMask_Photo: 512, mXttOpMethodsMask_Photo : 512,
mXttOpMethodsMask_Note: 1024, mXttOpMethodsMask_Note : 1024,
mXttOpMethodsMask_ParentObjectGraph: 2048, mXttOpMethodsMask_ParentObjectGraph : 2048,
mXttMntMethodsMask_OpenObject: 1, mXttMntMethodsMask_OpenObject : 1,
mXttMntMethodsMask_OpenTrace: 2, mXttMntMethodsMask_OpenTrace : 2,
mXttMntMethodsMask_RtNavigator: 4, mXttMntMethodsMask_RtNavigator : 4,
mXttMntMethodsMask_OpenCrossref: 8, mXttMntMethodsMask_OpenCrossref : 8,
mXttMntMethodsMask_HelpClass: 16, mXttMntMethodsMask_HelpClass : 16,
mXttMntMethodsMask_DataSheet: 32, mXttMntMethodsMask_DataSheet : 32,
mXttMntMethodsMask_CircuitDiagram: 64, mXttMntMethodsMask_CircuitDiagram : 64,
mXttMntMethodsMask_Simulate: 1 << 31 mXttMntMethodsMask_Simulate : 1 << 31
}; };
function PwrtObjid(vid, oix) { function PwrtObjid( vid, oix) {
this.oix = oix; this.oix = oix;
this.vid = vid; this.vid = vid;
} }
function CdhrNumber(value, sts) { function PwrtAttrRef() {
this.objid;
this.offset;
this.body;
this.size;
this.flags;
}
function CdhrNumber( value, sts)
{
this.value = value; this.value = value;
this.sts = sts; this.sts = sts;
this.evenSts = function () { return (sts % 2 === 0); }; this.evenSts = function() { return (sts % 2 === 0);};
this.oddSts = function () { return (sts % 2 === 1); }; this.oddSts = function() { return (sts % 2 == 1);};
this.getSts = function () { return sts; }; this.getSts = function() { return sts;};
} }
var CdhC = {
cUserVolMin : (0 + (0 << 24) + (1 << 16) + (1 << 8) + 1),
cUserVolMax : (0 + (0 << 24) + (254 << 16) + (254 << 8) + 254)
};
function UserdataCbReturn() {
this.userdata;
this.row;
}
/** End Pwr **/
/** Start Gdh **/ /** Start Gdh **/
function Sub() { function Sub() {
this.sts; this.sts;
...@@ -805,6 +837,7 @@ function ObjectInfo() { ...@@ -805,6 +837,7 @@ function ObjectInfo() {
this.description; this.description;
this.classname; this.classname;
this.full_name; this.full_name;
this.param1;
} }
function AttributeInfo() { function AttributeInfo() {
...@@ -865,82 +898,89 @@ function GlowTableInfo() { ...@@ -865,82 +898,89 @@ function GlowTableInfo() {
this.column_size = new Array(Glow.TABLE_MAX_COL); this.column_size = new Array(Glow.TABLE_MAX_COL);
} }
function PendingData(func_cb, data) { function PendingData( func_cb, data) {
this.func_cb = func_cb; this.func_cb = func_cb;
this.data = data; this.data = data;
} }
var GdhOp = { var GdhOp = {
GET_OP_SELF: 1, GET_OP_SELF : 1,
GET_OP_METHOD_PLC: 2 GET_OP_METHOD_PLC : 2,
GET_OP_METHOD_OBJECTGRAPH : 3,
GET_OP_METHOD_GRAPH : 4,
GET_OP_METHOD_HELPCLASS : 5
}; };
function Gdh() { function Gdh() {
var Msg = { var Msg = {
SET_OBJECT_INFO_BOOLEAN: 1, SET_OBJECT_INFO_BOOLEAN : 1,
SET_OBJECT_INFO_FLOAT: 2, SET_OBJECT_INFO_FLOAT : 2,
SET_OBJECT_INFO_INT: 3, SET_OBJECT_INFO_INT : 3,
SET_OBJECT_INFO_STRING: 4, SET_OBJECT_INFO_STRING : 4,
GET_OBJECT_INFO_BOOLEAN: 5, GET_OBJECT_INFO_BOOLEAN : 5,
GET_OBJECT_INFO_FLOAT: 6, GET_OBJECT_INFO_FLOAT : 6,
GET_OBJECT_INFO_INT: 7, GET_OBJECT_INFO_INT : 7,
GET_OBJECT_INFO_STRING: 8, GET_OBJECT_INFO_STRING : 8,
TOGGLE_OBJECT_INFO: 9, TOGGLE_OBJECT_INFO : 9,
REF_OBJECT_INFO: 10, REF_OBJECT_INFO : 10,
GET_OBJECT_REF_INFO_BOOLEAN: 11, GET_OBJECT_REF_INFO_BOOLEAN : 11,
GET_OBJECT_REF_INFO_FLOAT: 12, GET_OBJECT_REF_INFO_FLOAT : 12,
GET_OBJECT_REF_INFO_INT: 13, GET_OBJECT_REF_INFO_INT : 13,
GET_OBJECT_REF_INFO_STRING: 14, GET_OBJECT_REF_INFO_STRING : 14,
UNREF_OBJECT_INFO: 15, UNREF_OBJECT_INFO : 15,
NAME_TO_OBJID: 16, NAME_TO_OBJID : 16,
OBJID_TO_NAME: 17, OBJID_TO_NAME : 17,
GET_ROOT_LIST: 18, GET_ROOT_LIST : 18,
GET_NEXT_OBJECT: 19, GET_NEXT_OBJECT : 19,
GET_CHILD: 20, GET_CHILD : 20,
GET_NEXT_SIBLING: 21, GET_NEXT_SIBLING : 21,
GET_OBJECT_CLASS: 22, GET_OBJECT_CLASS : 22,
GET_CLASS_LIST: 23, GET_CLASS_LIST : 23,
CLASS_ID_TO_OBJID: 24, CLASS_ID_TO_OBJID : 24,
GET_OBJECT_REF_INFO_ALL: 25, GET_OBJECT_REF_INFO_ALL : 25,
REF_OBJECT_INFO_LIST: 26, REF_OBJECT_INFO_LIST : 26,
POLL: 27, POLL : 27,
STATISTICS: 28, STATISTICS : 28,
CHECK_USER: 29, CHECK_USER : 29,
GET_NODE_OBJECT: 30, GET_NODE_OBJECT : 30,
LOG_STRING: 31, LOG_STRING : 31,
UNREF_OBJECT_INFO_ALL: 32, UNREF_OBJECT_INFO_ALL : 32,
CREATE_INSTANCE_FILE: 33, CREATE_INSTANCE_FILE : 33,
GET_ATTRIBUTE_CHAR: 34, GET_ATTRIBUTE_CHAR : 34,
GET_CLASS_ATTRIBUTE: 35, GET_CLASS_ATTRIBUTE : 35,
GET_ALL_CLASS_ATTRIBUTES: 36, GET_ALL_CLASS_ATTRIBUTES : 36,
GET_ALL_SIBLINGS: 37, GET_ALL_SIBLINGS : 37,
GET_ALL_XTT_SIBLINGS: 38, GET_ALL_XTT_SIBLINGS : 38,
GET_ALL_XTT_CHILDREN: 39, GET_ALL_XTT_CHILDREN : 39,
REF_OBJECT_INFO_VECTOR: 40, REF_OBJECT_INFO_VECTOR : 40,
GET_SUBSCRIPTIONS: 41, GET_SUBSCRIPTIONS : 41,
CRR_SIGNAL: 42, CRR_SIGNAL : 42,
CRR_OBJECT: 43, CRR_OBJECT : 43,
GET_PARENT: 44, GET_PARENT : 44,
GET_OBJECT_INFO_OBJID: 45, GET_OBJECT_INFO_OBJID : 45,
GET_OBJECT_REF_INFO_BOOLEAN_ARRAY: 46, GET_OBJECT_REF_INFO_BOOLEAN_ARRAY : 46,
GET_OBJECT_REF_INFO_FLOAT_ARRAY: 47, GET_OBJECT_REF_INFO_FLOAT_ARRAY : 47,
GET_OBJECT_REF_INFO_INT_ARRAY: 48, GET_OBJECT_REF_INFO_INT_ARRAY : 48,
GET_OBJECT_REF_INFO_STRING_ARRAY: 49, GET_OBJECT_REF_INFO_STRING_ARRAY : 49,
GET_MSG: 50, GET_MSG : 50,
GET_MSG_TEXT: 51, GET_MSG_TEXT : 51,
NAME_TO_ATTRREF: 52, NAME_TO_ATTRREF : 52,
ATTRREF_TO_NAME: 53, ATTRREF_TO_NAME : 53,
GET_ATTRREF_TID: 54, GET_ATTRREF_TID : 54,
GET_SUPER_CLASS: 55, GET_SUPER_CLASS : 55,
GET_ALL_CLASS_ATTRIBUTES_STRING: 56, GET_ALL_CLASS_ATTRIBUTES_STRING : 56,
GET_OBJECT_INFO_FLOAT_ARRAY: 57, GET_OBJECT_INFO_FLOAT_ARRAY : 57,
GET_OBJECT_INFO_INT_ARRAY: 58, GET_OBJECT_INFO_INT_ARRAY : 58,
GET_CIRCBUFF_INFO: 59, GET_CIRCBUFF_INFO : 59,
UPDATE_CIRCBUFF_INFO: 60, UPDATE_CIRCBUFF_INFO : 60,
GET_ATTRIBUTE_FLAGS: 61, GET_ATTRIBUTE_FLAGS : 61,
CLASSNAME_TO_ID: 62, CLASSNAME_TO_ID : 62,
GET_OBJECT: 63, GET_OBJECT : 63,
GET_OPWIND_MENU: 64 GET_OPWIND_MENU : 64,
GET_OBJECT_FROM_NAME : 65,
MH_SYNC : 66,
MH_ACK : 67,
GET_OBJECT_FROM_AREF : 68
}; };
this.debug = false; this.debug = false;
...@@ -955,140 +995,155 @@ function Gdh() { ...@@ -955,140 +995,155 @@ function Gdh() {
this.subscriptionCount = 1; this.subscriptionCount = 1;
this.listSend = false; this.listSend = false;
this.init = function () { this.init = function() {
if (window.location.hostname === "") if ( window.location.hostname === "")
this.ws = new WebSocket("ws:127.0.0.1:4448"); this.ws = new WebSocket( "ws:127.0.0.1:4448");
else else
this.ws = new WebSocket("ws://" + window.location.hostname + ":4448"); this.ws = new WebSocket( "ws://" + window.location.hostname + ":4448");
this.ws.binaryType = "arraybuffer"; this.ws.binaryType = "arraybuffer";
this.ws.gdh = this; this.ws.gdh = this;
this.ws.onopen = function (e) { this.ws.onopen = function( e) {
if (this.gdh.open_cb !== null) if ( this.gdh.open_cb !== null)
this.gdh.open_cb(); this.gdh.open_cb();
}; };
this.ws.onclose = function () { this.ws.onclose = function() {
if (this.debug) console.log("Socket closed"); if ( this.debug) console.log( "Socket closed");
if (this.gdh.close_cb !== null) if ( this.gdh.close_cb !== null)
this.gdh.close_cb(); this.gdh.close_cb();
}; };
this.ws.onmessage = function (e) { this.ws.onmessage = function(e) {
if (typeof e.data === "string") { if ( typeof e.data == "string") {
console.log("String message received", e, e.data); console.log("String message received", e, e.data);
} else { }
if (e.data instanceof ArrayBuffer) { else {
if ( e.data instanceof ArrayBuffer) {
var dv = new DataView(e.data); var dv = new DataView(e.data);
var type = dv.getUint8(0); var type = dv.getUint8(0);
var id = dv.getUint32(1); var id = dv.getUint32(1);
var sts = dv.getUint32(5); var sts = dv.getUint32(5);
switch (type) { switch( type) {
case Msg.GET_OBJECT_INFO_BOOLEAN: { case Msg.GET_OBJECT_INFO_BOOLEAN: {
if (this.gdh.debug) console.log("GetObjectInfoBoolean received"); if ( this.gdh.debug) console.log("GetObjectInfoBoolean received");
var value = dv.getUint8(9); var value = dv.getUint8(9);
var func_cb = this.gdh.pending[id].func_cb; var func_cb = this.gdh.pending[id].func_cb;
func_cb(id, sts, value); func_cb( id, sts, value);
delete this.gdh.pending[id]; delete this.gdh.pending[id];
break; break;
} }
case Msg.GET_OBJECT_INFO_INT: { case Msg.GET_OBJECT_INFO_INT: {
if (this.gdh.debug) console.log("GetObjectInfoInt received"); if ( this.gdh.debug) console.log("GetObjectInfoInt received");
var value = dv.getUint32(9); var value = dv.getUint32(9);
var pending_data = this.gdh.pending[id]; var pending_data = this.gdh.pending[id];
pending_data.func_cb(id, pending_data.data, sts, value); pending_data.func_cb( id, pending_data.data, sts, value);
delete this.gdh.pending[id]; delete this.gdh.pending[id];
break; break;
} }
case Msg.GET_OBJECT_INFO_FLOAT: { case Msg.GET_OBJECT_INFO_FLOAT: {
if (this.gdh.debug) console.log("GetObjectInfoFloat received"); if ( this.gdh.debug) console.log("GetObjectInfoFloat received");
var value = dv.getFloat32(9); var value = dv.getFloat32(9);
var pending_data = this.gdh.pending[id]; var pending_data = this.gdh.pending[id];
pending_data.func_cb(id, pending_data.data, sts, value); pending_data.func_cb( id, pending_data.data, sts, value);
delete this.gdh.pending[id]; delete this.gdh.pending[id];
break; break;
} }
case Msg.GET_OBJECT_INFO_FLOAT_ARRAY: { case Msg.GET_OBJECT_INFO_FLOAT_ARRAY: {
if (this.gdh.debug) console.log("GetObjectInfoFloatArray received"); if ( this.gdh.debug) console.log("GetObjectInfoFloatArray received");
var asize = dv.getInt32(9); var asize = dv.getInt32(9);
var value = new Array(asize); var value = new Array(asize);
k = 13; k = 13;
for (var i = 0; i < asize; i++) { for ( var i = 0; i < asize; i++) {
value[i] = dv.getFloat32(k); value[i] = dv.getFloat32(k);
k += 4; k += 4;
} }
var pending_data = this.gdh.pending[id]; var pending_data = this.gdh.pending[id];
pending_data.func_cb(id, pending_data.data, sts, value); pending_data.func_cb( id, pending_data.data, sts, value);
delete this.gdh.pending[id]; delete this.gdh.pending[id];
break; break;
} }
case Msg.SET_OBJECT_INFO_BOOLEAN: { case Msg.SET_OBJECT_INFO_BOOLEAN: {
if (this.gdh.debug) console.log("SetObjectInfoBoolean received", id, sts); if ( this.gdh.debug) console.log("SetObjectInfoBoolean received", id, sts);
break; break;
} }
case Msg.SET_OBJECT_INFO_INT: { case Msg.SET_OBJECT_INFO_INT: {
if (this.gdh.debug) console.log("SetObjectInfoInt received", id, sts); if ( this.gdh.debug) console.log("SetObjectInfoInt received", id, sts);
break; break;
} }
case Msg.SET_OBJECT_INFO_FLOAT: { case Msg.SET_OBJECT_INFO_FLOAT: {
if (this.gdh.debug) console.log("SetObjectInfoFloat received", id, sts); if ( this.gdh.debug) console.log("SetObjectInfoFloat received", id, sts);
break; break;
} }
case Msg.SET_OBJECT_INFO_STRING: { case Msg.SET_OBJECT_INFO_STRING: {
if (this.gdh.debug) console.log("SetObjectInfoString received", id, sts); if ( this.gdh.debug) console.log("SetObjectInfoString received", id, sts);
break; break;
} }
case Msg.TOGGLE_OBJECT_INFO: { case Msg.TOGGLE_OBJECT_INFO: {
if (this.gdh.debug) console.log("ToggleObjectInfo received", id, sts); if ( this.gdh.debug) console.log("ToggleObjectInfo received", id, sts);
break; break;
} }
case Msg.REF_OBJECT_INFO: { case Msg.REF_OBJECT_INFO: {
if (this.gdh.debug) console.log("RefObjectInfo received", id, sts); if ( this.gdh.debug) console.log("RefObjectInfo received", id, sts);
delete this.gdh.pending[id]; delete this.gdh.pending[id];
break; break;
} }
case Msg.UNREF_OBJECT_INFO: { case Msg.UNREF_OBJECT_INFO: {
if (this.gdh.debug) console.log("UnrefObjectInfo received", id, sts); if ( this.gdh.debug) console.log("UnrefObjectInfo received", id, sts);
delete this.gdh.pending[id]; delete this.gdh.pending[id];
break; break;
} }
case Msg.REF_OBJECT_INFO_LIST: { case Msg.REF_OBJECT_INFO_LIST: {
if (this.gdh.debug) console.log("RefObjectInfoList received", id, sts); if ( this.gdh.debug) console.log("RefObjectInfoList received", id, sts);
var func_cb = this.gdh.pending[id].func_cb; var func_cb = this.gdh.pending[id].func_cb;
func_cb(id, sts); func_cb( id, sts);
delete this.gdh.pending[id]; delete this.gdh.pending[id];
break; break;
} }
case Msg.GET_OBJECT_REF_INFO_ALL: { case Msg.GET_OBJECT_REF_INFO_ALL: {
var j = 9; var j = 9;
var size = dv.getUint32(j); var size = dv.getUint32(j);
if (this.gdh.debug) console.log("GetObjectRefInfoAll received", id, size); if ( this.gdh.debug) console.log("GetObjectRefInfoAll received", id, size);
j += 4; j += 4;
for (var i = 0; i < size; i++) { for ( var i = 0; i < size; i++) {
var eid = dv.getUint32(j); var eid = dv.getUint32(j);
j += 4; j += 4;
var esize = dv.getUint32(j); var esize = dv.getUint32(j);
j += 4; j += 4;
var sub = this.gdh.sub[eid]; var sub = this.gdh.sub[eid];
if (typeof sub === 'undefined') if ( typeof sub == 'undefined')
j += esize; j += esize;
else { else {
var value; var value;
switch (sub.type) { switch ( sub.type) {
case Pwr.eType_Boolean: case Pwr.eType_Boolean:
if ( sub.elements <= 1) {
value = dv.getUint8(j); value = dv.getUint8(j);
j += 1; j += 1;
}
else {
var elements = esize;
if ( elements != sub.elements)
console.log("Subscription size error", elements, sub.elements, eid);
value = new Array(elements);
for ( var k = 0; k < elements; k++) {
value[k] = dv.getUint8(j);
j += 1;
}
}
break; break;
case Pwr.eType_Float32: case Pwr.eType_Float32:
if (sub.elements <= 1) { if ( sub.elements <= 1) {
value = dv.getFloat32(j); value = dv.getFloat32(j);
j += 4; j += 4;
} else { }
if (esize !== sub.elements * 4) else {
console.log("Subscription size error", esize, sub.elements, eid); var elements = esize / 4;
value = new Array(sub.elements); if ( elements != sub.elements)
for (var k = 0; k < sub.elements; k++) { console.log("Subscription size error", elements, sub.elements, eid);
value = new Array(elements);
for ( var k = 0; k < elements; k++) {
value[k] = dv.getFloat32(j); value[k] = dv.getFloat32(j);
j += 4; j += 4;
} }
...@@ -1101,35 +1156,66 @@ function Gdh() { ...@@ -1101,35 +1156,66 @@ function Gdh() {
case Pwr.eType_UInt16: case Pwr.eType_UInt16:
case Pwr.eType_UInt32: case Pwr.eType_UInt32:
case Pwr.eType_Status: case Pwr.eType_Status:
case Pwr.eType_NetStatus:
case Pwr.eType_Mask: case Pwr.eType_Mask:
case Pwr.eType_Enum: case Pwr.eType_Enum:
case GraphIfc.eType_Bit:
if ( sub.elements <= 1) {
value = dv.getInt32(j); value = dv.getInt32(j);
j += 4; j += 4;
}
else {
var elements = esize / 4;
if ( elements != sub.elements)
console.log("Subscription size error", elements, sub.elements, eid);
value = new Array(elements);
for ( var k = 0; k < elements; k++) {
value[k] = dv.getInt32(j);
j += 4;
}
}
break; break;
case Pwr.eType_String: case Pwr.eType_String:
case Pwr.eType_Time: case Pwr.eType_Time:
case Pwr.eType_DeltaTime: case Pwr.eType_DeltaTime:
case Pwr.eType_AttrRef: case Pwr.eType_AttrRef:
case Pwr.eType_Objid: case Pwr.eType_Objid:
if ( sub.elements <= 1) {
var nsize = dv.getInt16(j); var nsize = dv.getInt16(j);
j += 2; j += 2;
var iarr = new Uint8Array(nsize); var iarr = new Uint8Array( nsize);
for (var k = 0; k < nsize; k++) { for ( var k = 0; k < nsize; k++) {
iarr[k] = dv.getUint8(j++); iarr[k] = dv.getUint8(j++);
} }
value = String.fromCharCode.apply(null, iarr); value = String.fromCharCode.apply( null, iarr);
}
else {
var elements = sub.elements;
if ( elements != sub.elements)
console.log("Subscription size error", elements, sub.elements, eid);
value = new Array(elements);
for ( var l = 0; l < elements; l++) {
var nsize = dv.getInt16(j);
j += 2;
var iarr = new Uint8Array( nsize);
for ( var k = 0; k < nsize; k++) {
iarr[k] = dv.getUint8(j++);
}
value[l] = String.fromCharCode.apply( null, iarr);
}
}
break; break;
default: break; default: break;
} }
this.gdh.sub[eid].value = value; this.gdh.sub[eid].value = value;
} }
} }
if (typeof this.gdh.pending[id] === 'undefined') { if ( typeof this.gdh.pending[id] == 'undefined') {
console.log("** GetObjectRefInfoAll received removed", id); console.log( "** GetObjectRefInfoAll received removed", id);
break; break;
} }
var func_cb = this.gdh.pending[id].func_cb; var func_cb = this.gdh.pending[id].func_cb;
func_cb(id, sts); func_cb( id, sts);
delete this.gdh.pending[id]; delete this.gdh.pending[id];
break; break;
} }
...@@ -1137,10 +1223,10 @@ function Gdh() { ...@@ -1137,10 +1223,10 @@ function Gdh() {
var result = []; var result = [];
var j = 9; var j = 9;
var size = dv.getUint32(j); var size = dv.getUint32(j);
if (this.gdh.debug) console.log("GetAllXttChildren received", id, size); if ( this.gdh.debug) console.log("GetAllXttChildren received", id, size);
console.log("GetAllXttChildren received", sts, id, size); console.log("GetAllXttChildren received", sts, id, size);
j += 4; j += 4;
for (var i = 0; i < size; i++) { for ( var i = 0; i < size; i++) {
var info = new ObjectInfo(); var info = new ObjectInfo();
info.objid = new PwrtObjid(); info.objid = new PwrtObjid();
info.objid.vid = dv.getUint32(j); info.objid.vid = dv.getUint32(j);
...@@ -1153,30 +1239,30 @@ function Gdh() { ...@@ -1153,30 +1239,30 @@ function Gdh() {
j += 2; j += 2;
var nsize = dv.getUint16(j); var nsize = dv.getUint16(j);
j += 2; j += 2;
var iarr = new Uint8Array(nsize); var iarr = new Uint8Array( nsize);
for (var k = 0; k < nsize; k++) { for ( var k = 0; k < nsize; k++) {
iarr[k] = dv.getUint8(j++); iarr[k] = dv.getUint8(j++);
} }
info.name = String.fromCharCode.apply(null, iarr); info.name = String.fromCharCode.apply( null, iarr);
//j += nsize; //j += nsize;
var dsize = dv.getUint16(j); var dsize = dv.getUint16(j);
j += 2; j += 2;
iarr = new Uint8Array(dsize); iarr = new Uint8Array( dsize);
for (var k = 0; k < dsize; k++) { for ( var k = 0; k < dsize; k++) {
iarr[k] = dv.getUint8(j++); iarr[k] = dv.getUint8(j++);
} }
info.description = String.fromCharCode.apply(null, iarr); info.description = String.fromCharCode.apply( null, iarr);
var csize = dv.getUint16(j); var csize = dv.getUint16(j);
j += 2; j += 2;
iarr = new Uint8Array(csize); iarr = new Uint8Array( csize);
for (var k = 0; k < csize; k++) { for ( var k = 0; k < csize; k++) {
iarr[k] = dv.getUint8(j++); iarr[k] = dv.getUint8(j++);
} }
info.classname = String.fromCharCode.apply(null, iarr); info.classname = String.fromCharCode.apply( null, iarr);
result.push(info); result.push(info);
} }
var pending_data = this.gdh.pending[id]; var pending_data = this.gdh.pending[id];
pending_data.func_cb(id, pending_data.data, sts, result); pending_data.func_cb( id, pending_data.data, sts, result);
delete this.gdh.pending[id]; delete this.gdh.pending[id];
break; break;
} }
...@@ -1184,9 +1270,9 @@ function Gdh() { ...@@ -1184,9 +1270,9 @@ function Gdh() {
var result = []; var result = [];
var j = 9; var j = 9;
var size = dv.getUint32(j); var size = dv.getUint32(j);
if (this.gdh.debug) console.log("GetAllClassAttributes received", id, size); if ( this.gdh.debug) console.log("GetAllClassAttributes received", id, size);
j += 4; j += 4;
for (var i = 0; i < size; i++) { for ( var i = 0; i < size; i++) {
var info = new AttributeInfo(); var info = new AttributeInfo();
info.type = dv.getUint32(j); info.type = dv.getUint32(j);
j += 4; j += 4;
...@@ -1198,30 +1284,32 @@ function Gdh() { ...@@ -1198,30 +1284,32 @@ function Gdh() {
j += 2; j += 2;
var nsize = dv.getUint16(j); var nsize = dv.getUint16(j);
j += 2; j += 2;
var iarr = new Uint8Array(nsize); var iarr = new Uint8Array( nsize);
for (var k = 0; k < nsize; k++) { for ( var k = 0; k < nsize; k++) {
iarr[k] = dv.getUint8(j++); iarr[k] = dv.getUint8(j++);
} }
info.name = String.fromCharCode.apply(null, iarr); info.name = String.fromCharCode.apply( null, iarr);
nsize = dv.getUint16(j); nsize = dv.getUint16(j);
j += 2; j += 2;
iarr = new Uint8Array(nsize); iarr = new Uint8Array( nsize);
for (var k = 0; k < nsize; k++) { for ( var k = 0; k < nsize; k++) {
iarr[k] = dv.getUint8(j++); iarr[k] = dv.getUint8(j++);
} }
info.classname = String.fromCharCode.apply(null, iarr); info.classname = String.fromCharCode.apply( null, iarr);
result.push(info); result.push(info);
} }
var pending_data = this.gdh.pending[id]; var pending_data = this.gdh.pending[id];
pending_data.func_cb(id, pending_data.data, sts, result); pending_data.func_cb( id, pending_data.data, sts, result);
delete this.gdh.pending[id]; delete this.gdh.pending[id];
break; break;
} }
case Msg.GET_OBJECT: { case Msg.GET_OBJECT:
if (this.gdh.debug) console.log("GetObject received", id, sts); case Msg.GET_OBJECT_FROM_AREF:
case Msg.GET_OBJECT_FROM_NAME: {
if ( this.gdh.debug) console.log("GetObject received", id, sts);
var info = null; var info = null;
if ((sts & 1) !== 0) { if ( (sts & 1) !== 0) {
var j = 9; var j = 9;
info = new ObjectInfo(); info = new ObjectInfo();
info.objid = new PwrtObjid(); info.objid = new PwrtObjid();
...@@ -1236,50 +1324,58 @@ function Gdh() { ...@@ -1236,50 +1324,58 @@ function Gdh() {
var nsize = dv.getUint16(j); var nsize = dv.getUint16(j);
j += 2; j += 2;
var iarr = new Uint8Array(nsize); var iarr = new Uint8Array( nsize);
for (var k = 0; k < nsize; k++) { for ( var k = 0; k < nsize; k++) {
iarr[k] = dv.getUint8(j++); iarr[k] = dv.getUint8(j++);
} }
info.name = String.fromCharCode.apply(null, iarr); info.name = String.fromCharCode.apply( null, iarr);
nsize = dv.getUint16(j); nsize = dv.getUint16(j);
j += 2; j += 2;
iarr = new Uint8Array(nsize); iarr = new Uint8Array( nsize);
for (var k = 0; k < nsize; k++) { for ( var k = 0; k < nsize; k++) {
iarr[k] = dv.getUint8(j++); iarr[k] = dv.getUint8(j++);
} }
info.fullname = String.fromCharCode.apply(null, iarr); info.fullname = String.fromCharCode.apply( null, iarr);
var csize = dv.getUint16(j); var csize = dv.getUint16(j);
j += 2; j += 2;
iarr = new Uint8Array(csize); iarr = new Uint8Array( csize);
for (var k = 0; k < csize; k++) { for ( var k = 0; k < csize; k++) {
iarr[k] = dv.getUint8(j++); iarr[k] = dv.getUint8(j++);
} }
info.classname = String.fromCharCode.apply(null, iarr); info.classname = String.fromCharCode.apply( null, iarr);
var dsize = dv.getUint16(j); var dsize = dv.getUint16(j);
j += 2; j += 2;
iarr = new Uint8Array(dsize); iarr = new Uint8Array( dsize);
for (var k = 0; k < dsize; k++) { for ( var k = 0; k < dsize; k++) {
iarr[k] = dv.getUint8(j++); iarr[k] = dv.getUint8(j++);
} }
info.description = String.fromCharCode.apply(null, iarr); info.description = String.fromCharCode.apply( null, iarr);
var p1size = dv.getUint16(j);
j += 2;
iarr = new Uint8Array( p1size);
for ( var k = 0; k < p1size; k++) {
iarr[k] = dv.getUint8(j++);
}
info.param1 = String.fromCharCode.apply( null, iarr);
} }
var pending_data = this.gdh.pending[id]; var pending_data = this.gdh.pending[id];
pending_data.func_cb(id, pending_data.data, sts, info); pending_data.func_cb( id, pending_data.data, sts, info);
delete this.gdh.pending[id]; delete this.gdh.pending[id];
break; break;
} }
case Msg.CRR_SIGNAL: { case Msg.CRR_SIGNAL: {
var crrtext = null; var crrtext = null;
if ((sts & 1) !== 0) { if ( (sts & 1) !== 0) {
var j = 9; var j = 9;
var result = []; var result = [];
var size = dv.getUint16(j); var size = dv.getUint16(j);
j += 2; j += 2;
if (this.gdh.debug) console.log("CrrSignal received", id, size); if ( this.gdh.debug) console.log("CrrSignal received", id, size);
for (var i = 0; i < size; i++) { for ( var i = 0; i < size; i++) {
var info = new CrrInfo(); var info = new CrrInfo();
info.type = dv.getUint16(j); info.type = dv.getUint16(j);
j += 2; j += 2;
...@@ -1290,48 +1386,49 @@ function Gdh() { ...@@ -1290,48 +1386,49 @@ function Gdh() {
j += 4; j += 4;
var nsize = dv.getUint16(j); var nsize = dv.getUint16(j);
j += 2; j += 2;
var iarr = new Uint8Array(nsize); var iarr = new Uint8Array( nsize);
for (var k = 0; k < nsize; k++) { for ( var k = 0; k < nsize; k++) {
iarr[k] = dv.getUint8(j++); iarr[k] = dv.getUint8(j++);
} }
info.name = String.fromCharCode.apply(null, iarr); info.name = String.fromCharCode.apply( null, iarr);
var csize = dv.getUint16(j); var csize = dv.getUint16(j);
j += 2; j += 2;
iarr = new Uint8Array(csize); iarr = new Uint8Array( csize);
for (var k = 0; k < csize; k++) { for ( var k = 0; k < csize; k++) {
iarr[k] = dv.getUint8(j++); iarr[k] = dv.getUint8(j++);
} }
info.classname = String.fromCharCode.apply(null, iarr); info.classname = String.fromCharCode.apply( null, iarr);
result.push(info); result.push(info);
} }
} }
var pending_data = this.gdh.pending[id]; var pending_data = this.gdh.pending[id];
pending_data.func_cb(id, pending_data.data, sts, result); pending_data.func_cb( id, pending_data.data, sts, result);
delete this.gdh.pending[id]; delete this.gdh.pending[id];
break; break;
} }
case Msg.GET_OPWIND_MENU: { case Msg.GET_OPWIND_MENU: {
var result = new OpwindMenuInfo(); var result = new OpwindMenuInfo();
var j = 9; var j = 9;
if (this.gdh.debug) console.log("GetOpwindMenu received", id, size); if ( this.gdh.debug) console.log("GetOpwindMenu received", id, size);
console.log("GetOpwindMenu received", sts, id); console.log("GetOpwindMenu received", sts, id);
if (sts & 1) { if ( sts & 1) {
var nsize = dv.getUint16(j); var nsize = dv.getUint16(j);
j += 2; j += 2;
var iarr = new Uint8Array(nsize); var iarr = new Uint8Array( nsize);
for (var k = 0; k < nsize; k++) { for ( var k = 0; k < nsize; k++) {
iarr[k] = dv.getUint8(j++); iarr[k] = dv.getUint8(j++);
} }
result.title = String.fromCharCode.apply(null, iarr); result.title = String.fromCharCode.apply( null, iarr);
nsize = dv.getUint16(j); nsize = dv.getUint16(j);
j += 2; j += 2;
iarr = new Uint8Array(nsize); iarr = new Uint8Array( nsize);
for (var k = 0; k < nsize; k++) { for ( var k = 0; k < nsize; k++) {
iarr[k] = dv.getUint8(j++); iarr[k] = dv.getUint8(j++);
} }
result.text = String.fromCharCode.apply(null, iarr); result.text = String.fromCharCode.apply( null, iarr);
result.enable_language = dv.getUint32(j); result.enable_language = dv.getUint32(j);
j += 4; j += 4;
...@@ -1353,51 +1450,189 @@ function Gdh() { ...@@ -1353,51 +1450,189 @@ function Gdh() {
var bsize = dv.getUint16(j); var bsize = dv.getUint16(j);
j += 2; j += 2;
for (var i = 0; i < bsize; i++) { for ( var i = 0; i < bsize; i++) {
var button = new MenuButton(); var button = new MenuButton();
button.type = dv.getUint32(j); button.type = dv.getUint32(j);
j += 4; j += 4;
nsize = dv.getUint16(j); nsize = dv.getUint16(j);
j += 2; j += 2;
iarr = new Uint8Array(nsize); iarr = new Uint8Array( nsize);
for (var k = 0; k < nsize; k++) { for ( var k = 0; k < nsize; k++) {
iarr[k] = dv.getUint8(j++); iarr[k] = dv.getUint8(j++);
} }
button.text = String.fromCharCode.apply(null, iarr); button.text = String.fromCharCode.apply( null, iarr);
nsize = dv.getUint16(j); nsize = dv.getUint16(j);
j += 2; j += 2;
iarr = new Uint8Array(nsize); iarr = new Uint8Array( nsize);
for (var k = 0; k < nsize; k++) { for ( var k = 0; k < nsize; k++) {
iarr[k] = dv.getUint8(j++); iarr[k] = dv.getUint8(j++);
} }
button.name = String.fromCharCode.apply(null, iarr); button.name = String.fromCharCode.apply( null, iarr);
nsize = dv.getUint16(j); nsize = dv.getUint16(j);
j += 2; j += 2;
iarr = new Uint8Array(nsize); iarr = new Uint8Array( nsize);
for (var k = 0; k < nsize; k++) { for ( var k = 0; k < nsize; k++) {
iarr[k] = dv.getUint8(j++); iarr[k] = dv.getUint8(j++);
} }
button.url = String.fromCharCode.apply(null, iarr); button.url = String.fromCharCode.apply( null, iarr);
result.buttons.push(button); result.buttons.push(button);
} }
} }
var pending_data = this.gdh.pending[id]; var pending_data = this.gdh.pending[id];
pending_data.func_cb(id, pending_data.data, sts, result); pending_data.func_cb( id, pending_data.data, sts, result);
delete this.gdh.pending[id]; delete this.gdh.pending[id];
break; break;
} }
case Msg.CHECK_USER: { case Msg.CHECK_USER: {
var j = 9; var j = 9;
if (this.gdh.debug) console.log("Check user received", id, size); if ( this.gdh.debug) console.log("Check user received", id, size);
console.log("Check user received", sts, id); console.log("Check user received", sts, id);
var priv = 0; var priv = 0;
if (sts & 1) { if ( sts & 1) {
priv = dv.getUint32(j); priv = dv.getUint32(j);
j += 4; j += 4;
} }
var pending_data = this.gdh.pending[id]; var pending_data = this.gdh.pending[id];
pending_data.func_cb(id, pending_data.data, sts, priv); pending_data.func_cb( id, pending_data.data, sts, priv);
delete this.gdh.pending[id];
break;
}
case Msg.GET_MSG: {
if ( sts & 1) {
var j = 9;
var nsize = dv.getUint16(j);
j += 2;
var iarr = new Uint8Array( nsize);
for ( var k = 0; k < nsize; k++) {
iarr[k] = dv.getUint8(j++);
}
var msg = String.fromCharCode.apply( null, iarr);
}
var pending_data = this.gdh.pending[id];
pending_data.func_cb( id, pending_data.data, sts, msg);
delete this.gdh.pending[id];
break;
}
case Msg.MH_SYNC: {
var result = [];
var j = 9;
var size = dv.getUint32(j);
if ( this.gdh.debug) console.log("MhSync received", id, size);
j += 4;
for ( var i = 0; i < size; i++) {
var e = new MhEvent();
var len = dv.getUint16(j);
j += 2;
var iarr = new Uint8Array( len);
for ( var k = 0; k < len; k++) {
iarr[k] = dv.getUint8(j++);
}
e.eventTime = String.fromCharCode.apply( null, iarr);
len = dv.getUint16(j);
j += 2;
iarr = new Uint8Array( len);
for ( var k = 0; k < len; k++) {
iarr[k] = dv.getUint8(j++);
}
e.eventText = String.fromCharCode.apply( null, iarr);
len = dv.getUint16(j);
j += 2;
iarr = new Uint8Array( len);
for ( var k = 0; k < len; k++) {
iarr[k] = dv.getUint8(j++);
}
e.eventName = String.fromCharCode.apply( null, iarr);
e.eventFlags = dv.getUint32(j);
j += 4;
e.eventStatus = dv.getUint32(j);
j += 4;
e.eventPrio = dv.getUint32(j);
j += 4;
e.eventId = new MhEventId();
e.eventId.nix = dv.getUint32(j);
j += 4;
e.eventId.idx = dv.getUint32(j);
j += 4;
len = dv.getUint16(j);
j += 2;
iarr = new Uint8Array( len);
for ( var k = 0; k < len; k++) {
iarr[k] = dv.getUint8(j++);
}
e.eventId.birthTime = String.fromCharCode.apply( null, iarr);
e.targetId = new MhEventId();
e.targetId.nix = dv.getUint32(j);
j += 4;
e.targetId.idx = dv.getUint32(j);
j += 4;
len = dv.getUint16(j);
j += 2;
iarr = new Uint8Array( len);
for ( var k = 0; k < len; k++) {
iarr[k] = dv.getUint8(j++);
}
e.targetId.birthTime = String.fromCharCode.apply( null, iarr);
e.eventType = dv.getUint32(j);
j += 4;
var objid = new PwrtObjid(0,0);
objid.vid = dv.getUint32(j);
j += 4;
objid.oix = dv.getUint32(j);
j += 4;
e.object = new PwrtAttrRef();
e.object.objid = objid;
e.object.offset = dv.getUint32(j);
j += 4;
e.object.body = dv.getUint32(j);
j += 4;
e.object.size = dv.getUint32(j);
j += 4;
e.object.flags = dv.getUint32(j);
j += 4;
var supObjid = new PwrtObjid(0,0);
supObjid.vid = dv.getUint32(j);
j += 4;
supObjid.oix = dv.getUint32(j);
j += 4;
e.supObject = new PwrtAttrRef();
e.supObject.objid = supObjid;
e.supObject.offset = dv.getUint32(j);
j += 4;
e.supObject.body = dv.getUint32(j);
j += 4;
e.supObject.size = dv.getUint32(j);
j += 4;
e.supObject.flags = dv.getUint32(j);
j += 4;
len = dv.getUint16(j);
j += 2;
iarr = new Uint8Array( len);
for ( var k = 0; k < len; k++) {
iarr[k] = dv.getUint8(j++);
}
e.eventMoreText = String.fromCharCode.apply( null, iarr);
e.syncIdx = dv.getUint32(j);
j += 4;
result.push(e);
}
var pending_data = this.gdh.pending[id];
pending_data.func_cb( id, pending_data.data, sts, result);
delete this.gdh.pending[id];
break;
}
case Msg.MH_ACK: {
var pending_data = this.gdh.pending[id];
pending_data.func_cb( id, pending_data.data, sts);
delete this.gdh.pending[id]; delete this.gdh.pending[id];
break; break;
} }
...@@ -1409,61 +1644,61 @@ function Gdh() { ...@@ -1409,61 +1644,61 @@ function Gdh() {
}; };
}; };
this.getObjectInfoBoolean = function (name, return_cb) { this.getObjectInfoBoolean = function( name, return_cb) {
this.return_cb = return_cb; this.return_cb = return_cb;
var buf = new Uint8Array(name.length + 6); var buf = new Uint8Array(name.length+6);
buf[0] = Msg.GET_OBJECT_INFO_BOOLEAN; buf[0] = Msg.GET_OBJECT_INFO_BOOLEAN;
buf[2] = this.next_id & 0xFF; buf[2] = this.next_id & 0xFF;
buf[3] = (this.next_id >> 8) & 0xFF; buf[3] = (this.next_id >> 8) & 0xFF;
buf[4] = (this.next_id >> 16) & 0xFF; buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF; buf[5] = (this.next_id >> 24) & 0xFF;
for (var i = 0; i < name.length; i++) { for ( var i = 0; i < name.length; i++) {
buf[i + 6] = name.charCodeAt(i); buf[i+6] = name.charCodeAt(i);
} }
this.pending[this.next_id] = new PendingData(return_cb, null); this.pending[this.next_id] = new PendingData( return_cb, null);
this.ws.send(buf); this.ws.send(buf);
this.next_id++; this.next_id++;
}; };
this.getObjectInfoInt = function (name, return_cb, data) { this.getObjectInfoInt = function( name, return_cb, data) {
this.return_cb = return_cb; this.return_cb = return_cb;
var buf = new Uint8Array(name.length + 6); var buf = new Uint8Array(name.length+6);
buf[0] = Msg.GET_OBJECT_INFO_INT; buf[0] = Msg.GET_OBJECT_INFO_INT;
buf[2] = this.next_id & 0xFF; buf[2] = this.next_id & 0xFF;
buf[3] = (this.next_id >> 8) & 0xFF; buf[3] = (this.next_id >> 8) & 0xFF;
buf[4] = (this.next_id >> 16) & 0xFF; buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF; buf[5] = (this.next_id >> 24) & 0xFF;
for (var i = 0; i < name.length; i++) { for ( var i = 0; i < name.length; i++) {
buf[i + 6] = name.charCodeAt(i); buf[i+6] = name.charCodeAt(i);
} }
this.pending[this.next_id] = new PendingData(return_cb, data); this.pending[this.next_id] = new PendingData( return_cb, data);
this.ws.send(buf); this.ws.send(buf);
this.next_id++; this.next_id++;
}; };
this.getObjectInfoFloat = function (name, return_cb, data) { this.getObjectInfoFloat = function( name, return_cb, data) {
this.return_cb = return_cb; this.return_cb = return_cb;
var buf = new Uint8Array(name.length + 6); var buf = new Uint8Array(name.length+6);
buf[0] = Msg.GET_OBJECT_INFO_FLOAT; buf[0] = Msg.GET_OBJECT_INFO_FLOAT;
buf[2] = this.next_id & 0xFF; buf[2] = this.next_id & 0xFF;
buf[3] = (this.next_id >> 8) & 0xFF; buf[3] = (this.next_id >> 8) & 0xFF;
buf[4] = (this.next_id >> 16) & 0xFF; buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF; buf[5] = (this.next_id >> 24) & 0xFF;
for (var i = 0; i < name.length; i++) { for ( var i = 0; i < name.length; i++) {
buf[i + 6] = name.charCodeAt(i); buf[i+6] = name.charCodeAt(i);
} }
this.pending[this.next_id] = new PendingData(return_cb, data); this.pending[this.next_id] = new PendingData( return_cb, data);
this.ws.send(buf); this.ws.send(buf);
this.next_id++; this.next_id++;
}; };
this.getObjectInfoFloatArray = function (name, asize, return_cb, data) { this.getObjectInfoFloatArray = function( name, asize, return_cb, data) {
this.return_cb = return_cb; this.return_cb = return_cb;
var buf = new Uint8Array(name.length + 10); var buf = new Uint8Array(name.length+10);
buf[0] = Msg.GET_OBJECT_INFO_FLOAT_ARRAY; buf[0] = Msg.GET_OBJECT_INFO_FLOAT_ARRAY;
buf[2] = this.next_id & 0xFF; buf[2] = this.next_id & 0xFF;
buf[3] = (this.next_id >> 8) & 0xFF; buf[3] = (this.next_id >> 8) & 0xFF;
...@@ -1473,15 +1708,15 @@ function Gdh() { ...@@ -1473,15 +1708,15 @@ function Gdh() {
buf[7] = (asize >> 8) & 0xFF; buf[7] = (asize >> 8) & 0xFF;
buf[8] = (asize >> 16) & 0xFF; buf[8] = (asize >> 16) & 0xFF;
buf[9] = (asize >> 24) & 0xFF; buf[9] = (asize >> 24) & 0xFF;
for (var i = 0; i < name.length; i++) { for ( var i = 0; i < name.length; i++) {
buf[i + 10] = name.charCodeAt(i); buf[i+10] = name.charCodeAt(i);
} }
this.pending[this.next_id] = new PendingData(return_cb, data); this.pending[this.next_id] = new PendingData( return_cb, data);
this.ws.send(buf); this.ws.send(buf);
this.next_id++; this.next_id++;
}; };
this.refObjectInfo = function (name, type, elements) { this.refObjectInfo = function( name, type, elements) {
var sub = new Sub(); var sub = new Sub();
sub.name = name; sub.name = name;
sub.refid = this.subscriptionCount; sub.refid = this.subscriptionCount;
...@@ -1489,20 +1724,22 @@ function Gdh() { ...@@ -1489,20 +1724,22 @@ function Gdh() {
sub.elements = elements; sub.elements = elements;
this.sub[this.subscriptionCount] = sub; this.sub[this.subscriptionCount] = sub;
this.subscriptionCount++; this.subscriptionCount++;
if (!this.listSent) { if ( !this.listSent) {
return sub.refid; return sub.refid;
} else { }
else {
var size = 0;
var len = 0; var len = 0;
var size = 12 + sub.name.length; size = 12 + sub.name.length;
var buf = new Uint8Array(size + 10); var buf = new Uint8Array(size+10);
buf[0] = Msg.REF_OBJECT_INFO; buf[0] = Msg.REF_OBJECT_INFO;
buf[2] = this.next_id & 0xFF; buf[2] = this.next_id & 0xFF;
buf[3] = (this.next_id >> 8) & 0xFF; buf[3] = (this.next_id >> 8) & 0xFF;
buf[4] = (this.next_id >> 16) & 0xFF; buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF; buf[5] = (this.next_id >> 24) & 0xFF;
if (this.debug) console.log("RefObjectInfo: ", sub.refid); if ( this.debug) console.log("RefObjectInfo: ", sub.refid);
var k = 6; var k = 6;
buf[k++] = sub.refid & 0xFF; buf[k++] = sub.refid & 0xFF;
buf[k++] = (sub.refid >> 8) & 0xFF; buf[k++] = (sub.refid >> 8) & 0xFF;
...@@ -1517,12 +1754,12 @@ function Gdh() { ...@@ -1517,12 +1754,12 @@ function Gdh() {
buf[k++] = (sub.name.length >> 16) & 0xFF; buf[k++] = (sub.name.length >> 16) & 0xFF;
buf[k++] = (sub.name.length >> 24) & 0xFF; buf[k++] = (sub.name.length >> 24) & 0xFF;
for (var j = 0; j < sub.name.length; j++) { for ( var j = 0; j < sub.name.length; j++) {
buf[k++] = sub.name.charCodeAt(j); buf[k++] = sub.name.charCodeAt(j);
} }
this.pending[this.next_id] = new PendingData(this.refObjectInfoReply, null); this.pending[this.next_id] = new PendingData( this.refObjectInfoReply, null);
if (this.debug) console.log("Sending RefObjectInfo", this.next_id, size, k); if ( this.debug) console.log( "Sending RefObjectInfo", this.next_id, size, k);
this.ws.send(buf); this.ws.send(buf);
this.next_id++; this.next_id++;
...@@ -1530,46 +1767,46 @@ function Gdh() { ...@@ -1530,46 +1767,46 @@ function Gdh() {
return sub.refid; return sub.refid;
} }
}; };
this.refObjectInfoReply = function (id, sts) { this.refObjectInfoReply = function( id, sts) {
if (this.debug) console.log("refObjectInfoReply", id, sts); if ( this.debug) console.log( "refObjectInfoReply", id, sts);
}; };
this.unrefObjectInfo = function (refid) { this.unrefObjectInfo = function( refid) {
var size = 0;
var len = 0; var len = 0;
var size = 4; size = 4;
var buf = new Uint8Array(size + 10); var buf = new Uint8Array(size+10);
buf[0] = Msg.UNREF_OBJECT_INFO; buf[0] = Msg.UNREF_OBJECT_INFO;
buf[2] = this.next_id & 0xFF; buf[2] = this.next_id & 0xFF;
buf[3] = (this.next_id >> 8) & 0xFF; buf[3] = (this.next_id >> 8) & 0xFF;
buf[4] = (this.next_id >> 16) & 0xFF; buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF; buf[5] = (this.next_id >> 24) & 0xFF;
if (this.debug) console.log("UnrefObjectInfo: ", refid); if ( this.debug) console.log("UnrefObjectInfo: ", refid);
var k = 6; var k = 6;
buf[k++] = refid & 0xFF; buf[k++] = refid & 0xFF;
buf[k++] = (refid >> 8) & 0xFF; buf[k++] = (refid >> 8) & 0xFF;
buf[k++] = (refid >> 16) & 0xFF; buf[k++] = (refid >> 16) & 0xFF;
buf[k++] = (refid >> 24) & 0xFF; buf[k++] = (refid >> 24) & 0xFF;
this.pending[this.next_id] = new PendingData(this.unrefObjectInfoReply, null); this.pending[this.next_id] = new PendingData( this.unrefObjectInfoReply, null);
if (this.debug) console.log("Sending UnrefObjectInfo", this.next_id, size, k, refid); if ( this.debug) console.log( "Sending UnrefObjectInfo", this.next_id, size, k, refid);
console.log("Sending UnrefObjectInfo", this.next_id, size, k, refid);
this.ws.send(buf); this.ws.send(buf);
this.next_id++; this.next_id++;
delete this.sub[refid]; delete this.sub[refid];
}; };
this.refObjectInfoList = function (return_cb) { this.refObjectInfoList = function( return_cb) {
var size = 0; var size = 0;
var len = 0; var len = 0;
this.return_cb = return_cb; this.return_cb = return_cb;
for (var i in this.sub) { for( var i in this.sub) {
size += 12 + this.sub[i].name.length; size += 12 + this.sub[i].name.length;
len++; len++;
} }
var buf = new Uint8Array(size + 10); var buf = new Uint8Array(size+10);
buf[0] = Msg.REF_OBJECT_INFO_LIST; buf[0] = Msg.REF_OBJECT_INFO_LIST;
buf[2] = this.next_id & 0xFF; buf[2] = this.next_id & 0xFF;
buf[3] = (this.next_id >> 8) & 0xFF; buf[3] = (this.next_id >> 8) & 0xFF;
...@@ -1580,10 +1817,10 @@ function Gdh() { ...@@ -1580,10 +1817,10 @@ function Gdh() {
buf[8] = (len >> 16) & 0xFF; buf[8] = (len >> 16) & 0xFF;
buf[9] = (len >> 24) & 0xFF; buf[9] = (len >> 24) & 0xFF;
var k = 10; var k = 10;
for (var i in this.sub) { for ( var i in this.sub) {
if (i === 0) if ( i === 0)
continue; continue;
if (this.debug) console.log("RefObjectInfoList: ", this.sub[i].refid); if ( this.debug) console.log("RefObjectInfoList: ", this.sub[i].refid);
buf[k++] = this.sub[i].refid & 0xFF; buf[k++] = this.sub[i].refid & 0xFF;
buf[k++] = (this.sub[i].refid >> 8) & 0xFF; buf[k++] = (this.sub[i].refid >> 8) & 0xFF;
buf[k++] = (this.sub[i].refid >> 16) & 0xFF; buf[k++] = (this.sub[i].refid >> 16) & 0xFF;
...@@ -1597,40 +1834,40 @@ function Gdh() { ...@@ -1597,40 +1834,40 @@ function Gdh() {
buf[k++] = (this.sub[i].name.length >> 16) & 0xFF; buf[k++] = (this.sub[i].name.length >> 16) & 0xFF;
buf[k++] = (this.sub[i].name.length >> 24) & 0xFF; buf[k++] = (this.sub[i].name.length >> 24) & 0xFF;
for (var j = 0; j < this.sub[i].name.length; j++) { for ( var j = 0; j < this.sub[i].name.length; j++) {
buf[k++] = this.sub[i].name.charCodeAt(j); buf[k++] = this.sub[i].name.charCodeAt(j);
} }
} }
this.pending[this.next_id] = new PendingData(return_cb, null); this.pending[this.next_id] = new PendingData( return_cb, null);
if (this.debug) console.log("Sending RefObjectInfoList", this.next_id, size, k, this.next_id); if ( this.debug) console.log( "Sending RefObjectInfoList", this.next_id, size, k, this.next_id);
this.ws.send(buf); this.ws.send(buf);
this.next_id++; this.next_id++;
this.listSent = true; this.listSent = true;
}; };
this.refObjectInfoListReply = function (id, sts) { this.refObjectInfoListReply = function( id, sts) {
if (this.debug) console.log("refObjectInfoListReply", id, sts); if ( this.debug) console.log( "refObjectInfoListReply", id, sts);
}; };
this.getRefObjectInfoAll = function (return_cb) { this.getRefObjectInfoAll = function( return_cb) {
var buf = new Uint8Array(6); var buf = new Uint8Array(6);
buf[0] = Msg.GET_OBJECT_REF_INFO_ALL; buf[0] = Msg.GET_OBJECT_REF_INFO_ALL;
buf[2] = this.next_id & 0xFF; buf[2] = this.next_id & 0xFF;
buf[3] = (this.next_id >> 8) & 0xFF; buf[3] = (this.next_id >> 8) & 0xFF;
buf[4] = (this.next_id >> 16) & 0xFF; buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF; buf[5] = (this.next_id >> 24) & 0xFF;
this.pending[this.next_id] = new PendingData(return_cb, null); this.pending[this.next_id] = new PendingData( return_cb, null);
if (this.debug) console.log("Sending getRefObjectInfoAll", this.next_id); if ( this.debug) console.log( "Sending getRefObjectInfoAll", this.next_id);
this.ws.send(buf); this.ws.send(buf);
this.next_id++; this.next_id++;
}; };
this.getRefObjectInfoAllReply = function (id, sts) { this.getRefObjectInfoAllReply = function( id, sts) {
if (this.debug) console.log("getRefObjectInfoAllReply", id, sts); if ( this.debug) console.log( "getRefObjectInfoAllReply", id, sts);
}; };
this.getObjectRefInfo = function (id) { this.getObjectRefInfo = function( id) {
if (this.debug) console.log("getObjectRefInfo", id, this.sub[id].value); if ( this.debug) console.log("getObjectRefInfo", id, this.sub[id].value);
return this.sub[id].value; return this.sub[id].value;
}; };
this.setObjectInfoBoolean = function (name, value) { this.setObjectInfoBoolean = function( name, value) {
var buf = new Uint8Array(12 + name.length); var buf = new Uint8Array(12 + name.length);
buf[0] = Msg.SET_OBJECT_INFO_BOOLEAN; buf[0] = Msg.SET_OBJECT_INFO_BOOLEAN;
buf[2] = this.next_id & 0xFF; buf[2] = this.next_id & 0xFF;
...@@ -1644,17 +1881,17 @@ function Gdh() { ...@@ -1644,17 +1881,17 @@ function Gdh() {
buf[10] = name.length & 0xFF; buf[10] = name.length & 0xFF;
buf[11] = (name.length >> 8) & 0xFF; buf[11] = (name.length >> 8) & 0xFF;
var k = 12; var k = 12;
for (var i = 0; i < name.length; i++) { for ( var i = 0; i < name.length; i++) {
buf[k++] = name.charCodeAt(i); buf[k++] = name.charCodeAt(i);
} }
this.ws.send(buf); this.ws.send(buf);
if (this.debug) console.log("Sending setObjectInfoBoolean", this.next_id, name, value); if ( this.debug) console.log("Sending setObjectInfoBoolean", this.next_id, name, value);
this.next_id++; this.next_id++;
return new PwrtStatus(1); return new PwrtStatus( 1);
}; };
this.setObjectInfoInt = function (name, value) { this.setObjectInfoInt = function( name, value) {
var buf = new Uint8Array(12 + name.length); var buf = new Uint8Array(12 + name.length);
buf[0] = Msg.SET_OBJECT_INFO_INT; buf[0] = Msg.SET_OBJECT_INFO_INT;
buf[2] = this.next_id & 0xFF; buf[2] = this.next_id & 0xFF;
...@@ -1668,18 +1905,18 @@ function Gdh() { ...@@ -1668,18 +1905,18 @@ function Gdh() {
buf[10] = name.length & 0xFF; buf[10] = name.length & 0xFF;
buf[11] = (name.length >> 8) & 0xFF; buf[11] = (name.length >> 8) & 0xFF;
var k = 12; var k = 12;
for (var i = 0; i < name.length; i++) { for ( var i = 0; i < name.length; i++) {
buf[k++] = name.charCodeAt(i); buf[k++] = name.charCodeAt(i);
} }
// this.pending[this.next_id] = new PendingData( return_cb, null); // this.pending[this.next_id] = new PendingData( return_cb, null);
this.ws.send(buf); this.ws.send(buf);
if (this.debug) console.log("Sending setObjectInfoInt", this.next_id, name, value); if ( this.debug) console.log("Sending setObjectInfoInt", this.next_id, name, value);
this.next_id++; this.next_id++;
return new PwrtStatus(1); return new PwrtStatus( 1);
}; };
this.setObjectInfoFloat = function (name, value) { this.setObjectInfoFloat = function( name, value) {
var buf = new Uint8Array(12 + name.length); var buf = new Uint8Array(12 + name.length);
buf[0] = Msg.SET_OBJECT_INFO_FLOAT; buf[0] = Msg.SET_OBJECT_INFO_FLOAT;
buf[2] = this.next_id & 0xFF; buf[2] = this.next_id & 0xFF;
...@@ -1697,20 +1934,20 @@ function Gdh() { ...@@ -1697,20 +1934,20 @@ function Gdh() {
buf[10] = name.length & 0xFF; buf[10] = name.length & 0xFF;
buf[11] = (name.length >> 8) & 0xFF; buf[11] = (name.length >> 8) & 0xFF;
var k = 12; var k = 12;
for (var i = 0; i < name.length; i++) { for ( var i = 0; i < name.length; i++) {
buf[k++] = name.charCodeAt(i); buf[k++] = name.charCodeAt(i);
} }
// this.pending[this.next_id] = new PendingData( return_cb, null); // this.pending[this.next_id] = new PendingData( return_cb, null);
this.ws.send(buf); this.ws.send(buf);
if (this.debug) console.log("Sending setObjectInfoFloat", this.next_id, name, value); if ( this.debug) console.log("Sending setObjectInfoFloat", this.next_id, name, value);
this.next_id++; this.next_id++;
return new PwrtStatus(1); return new PwrtStatus( 1);
}; };
this.setObjectInfoString = function (name, value) { this.setObjectInfoString = function( name, value) {
var i; var i;
var buf = new Uint8Array(10 + value.length + name.length); var buf = new Uint8Array( 10 + value.length + name.length);
buf[0] = Msg.SET_OBJECT_INFO_STRING; buf[0] = Msg.SET_OBJECT_INFO_STRING;
buf[2] = this.next_id & 0xFF; buf[2] = this.next_id & 0xFF;
buf[3] = (this.next_id >> 8) & 0xFF; buf[3] = (this.next_id >> 8) & 0xFF;
...@@ -1719,22 +1956,22 @@ function Gdh() { ...@@ -1719,22 +1956,22 @@ function Gdh() {
buf[6] = value.length & 0xFF; buf[6] = value.length & 0xFF;
buf[7] = (value.length >> 8) & 0xFF; buf[7] = (value.length >> 8) & 0xFF;
var k = 8; var k = 8;
for (i = 0; i < value.length; i++) for ( i = 0; i < value.length; i++)
buf[k++] = value.charCodeAt(i); buf[k++] = value.charCodeAt(i);
buf[k++] = name.length & 0xFF; buf[k++] = name.length & 0xFF;
buf[k++] = (name.length >> 8) & 0xFF; buf[k++] = (name.length >> 8) & 0xFF;
for (i = 0; i < name.length; i++) { for ( i = 0; i < name.length; i++) {
buf[k++] = name.charCodeAt(i); buf[k++] = name.charCodeAt(i);
} }
// this.pending[this.next_id] = new PendingData( return_cb, null); // this.pending[this.next_id] = new PendingData( return_cb, null);
this.ws.send(buf); this.ws.send(buf);
if (this.debug) console.log("Sending setObjectInfoString", this.next_id, name, value); if ( this.debug) console.log("Sending setObjectInfoString", this.next_id, name, value);
this.next_id++; this.next_id++;
return new PwrtStatus(1); return new PwrtStatus( 1);
}; };
this.toggleObjectInfo = function (name) { this.toggleObjectInfo = function( name) {
var buf = new Uint8Array(8 + name.length); var buf = new Uint8Array(8 + name.length);
buf[0] = Msg.TOGGLE_OBJECT_INFO; buf[0] = Msg.TOGGLE_OBJECT_INFO;
buf[2] = this.next_id & 0xFF; buf[2] = this.next_id & 0xFF;
...@@ -1744,18 +1981,18 @@ function Gdh() { ...@@ -1744,18 +1981,18 @@ function Gdh() {
buf[6] = name.length & 0xFF; buf[6] = name.length & 0xFF;
buf[7] = (name.length >> 8) & 0xFF; buf[7] = (name.length >> 8) & 0xFF;
var k = 8; var k = 8;
for (var i = 0; i < name.length; i++) { for ( var i = 0; i < name.length; i++) {
buf[k++] = name.charCodeAt(i); buf[k++] = name.charCodeAt(i);
} }
// this.pending[this.next_id] = new PendingData( return_cb, null); // this.pending[this.next_id] = new PendingData( return_cb, null);
this.ws.send(buf); this.ws.send(buf);
if (this.debug) console.log("Sending toggleObjectInfoBoolean", this.next_id, name, value); if ( this.debug) console.log("Sending toggleObjectInfoBoolean", this.next_id, name, value);
this.next_id++; this.next_id++;
return new PwrtStatus(1); return new PwrtStatus( 1);
}; };
this.getAllXttChildren = function (oid, return_cb, data) { this.getAllXttChildren = function( oid, return_cb, data) {
var buf = new Uint8Array(14); var buf = new Uint8Array(14);
buf[0] = Msg.GET_ALL_XTT_CHILDREN; buf[0] = Msg.GET_ALL_XTT_CHILDREN;
buf[2] = this.next_id & 0xFF; buf[2] = this.next_id & 0xFF;
...@@ -1770,13 +2007,13 @@ function Gdh() { ...@@ -1770,13 +2007,13 @@ function Gdh() {
buf[11] = (oid.oix >> 8) & 0xFF; buf[11] = (oid.oix >> 8) & 0xFF;
buf[12] = (oid.oix >> 16) & 0xFF; buf[12] = (oid.oix >> 16) & 0xFF;
buf[13] = (oid.oix >> 24) & 0xFF; buf[13] = (oid.oix >> 24) & 0xFF;
this.pending[this.next_id] = new PendingData(return_cb, data); this.pending[this.next_id] = new PendingData( return_cb, data);
if (this.debug) console.log("Sending getAllXttChildren", this.next_id); if ( this.debug) console.log( "Sending getAllXttChildren", this.next_id);
this.ws.send(buf); this.ws.send(buf);
this.next_id++; this.next_id++;
}; };
this.getAllClassAttributes = function (cid, oid, return_cb, data) { this.getAllClassAttributes = function( cid, oid, return_cb, data) {
var buf = new Uint8Array(18); var buf = new Uint8Array(18);
buf[0] = Msg.GET_ALL_CLASS_ATTRIBUTES; buf[0] = Msg.GET_ALL_CLASS_ATTRIBUTES;
buf[2] = this.next_id & 0xFF; buf[2] = this.next_id & 0xFF;
...@@ -1795,13 +2032,13 @@ function Gdh() { ...@@ -1795,13 +2032,13 @@ function Gdh() {
buf[15] = (oid.oix >> 8) & 0xFF; buf[15] = (oid.oix >> 8) & 0xFF;
buf[16] = (oid.oix >> 16) & 0xFF; buf[16] = (oid.oix >> 16) & 0xFF;
buf[17] = (oid.oix >> 24) & 0xFF; buf[17] = (oid.oix >> 24) & 0xFF;
this.pending[this.next_id] = new PendingData(return_cb, data); this.pending[this.next_id] = new PendingData( return_cb, data);
if (this.debug) console.log("Sending getAllClassAttributes", this.next_id, cid, oid.vid, oid.oix); if ( this.debug) console.log( "Sending getAllClassAttributes", this.next_id, cid, oid.vid, oid.oix);
this.ws.send(buf); this.ws.send(buf);
this.next_id++; this.next_id++;
}; };
this.getObject = function (oid, op, return_cb, data) { this.getObject = function( oid, op, return_cb, data) {
var buf = new Uint8Array(16); var buf = new Uint8Array(16);
buf[0] = Msg.GET_OBJECT; buf[0] = Msg.GET_OBJECT;
buf[2] = this.next_id & 0xFF; buf[2] = this.next_id & 0xFF;
...@@ -1818,13 +2055,73 @@ function Gdh() { ...@@ -1818,13 +2055,73 @@ function Gdh() {
buf[13] = (oid.oix >> 8) & 0xFF; buf[13] = (oid.oix >> 8) & 0xFF;
buf[14] = (oid.oix >> 16) & 0xFF; buf[14] = (oid.oix >> 16) & 0xFF;
buf[15] = (oid.oix >> 24) & 0xFF; buf[15] = (oid.oix >> 24) & 0xFF;
this.pending[this.next_id] = new PendingData(return_cb, data); this.pending[this.next_id] = new PendingData( return_cb, data);
if (this.debug) console.log("Sending getObject", this.next_id, oid.vid, oid.oix); if ( this.debug) console.log( "Sending getObject", this.next_id, oid.vid, oid.oix);
this.ws.send(buf);
this.next_id++;
};
this.getObjectFromAref = function( aref, op, return_cb, data) {
var buf = new Uint8Array(32);
buf[0] = Msg.GET_OBJECT_FROM_AREF;
buf[2] = this.next_id & 0xFF;
buf[3] = (this.next_id >> 8) & 0xFF;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
buf[6] = op & 0xFF;
buf[7] = (op >> 8) & 0xFF;
buf[8] = aref.objid.vid & 0xFF;
buf[9] = (aref.objid.vid >> 8) & 0xFF;
buf[10] = (aref.objid.vid >> 16) & 0xFF;
buf[11] = (aref.objid.vid >> 24) & 0xFF;
buf[12] = aref.objid.oix & 0xFF;
buf[13] = (aref.objid.oix >> 8) & 0xFF;
buf[14] = (aref.objid.oix >> 16) & 0xFF;
buf[15] = (aref.objid.oix >> 24) & 0xFF;
buf[16] = aref.offset & 0xFF;
buf[17] = (aref.offset >> 8) & 0xFF;
buf[18] = (aref.offset >> 16) & 0xFF;
buf[19] = (aref.offset >> 24) & 0xFF;
buf[20] = aref.body & 0xFF;
buf[21] = (aref.body >> 8) & 0xFF;
buf[22] = (aref.body >> 16) & 0xFF;
buf[23] = (aref.body >> 24) & 0xFF;
buf[24] = aref.size & 0xFF;
buf[25] = (aref.size >> 8) & 0xFF;
buf[26] = (aref.size >> 16) & 0xFF;
buf[27] = (aref.size >> 24) & 0xFF;
buf[28] = aref.flags & 0xFF;
buf[29] = (aref.flags >> 8) & 0xFF;
buf[30] = (aref.flags >> 16) & 0xFF;
buf[31] = (aref.flags >> 24) & 0xFF;
this.pending[this.next_id] = new PendingData( return_cb, data);
if ( this.debug) console.log( "Sending getObject", this.next_id, oid.vid, oid.oix);
this.ws.send(buf); this.ws.send(buf);
this.next_id++; this.next_id++;
}; };
this.crrSignal = function (oid, return_cb, data) { this.getObjectFromName = function( name, op, return_cb, data) {
var buf = new Uint8Array(10 + name.length);
buf[0] = Msg.GET_OBJECT_FROM_NAME;
buf[2] = this.next_id & 0xFF;
buf[3] = (this.next_id >> 8) & 0xFF;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
buf[6] = op & 0xFF;
buf[7] = (op >> 8) & 0xFF;
buf[8] = name.length & 0xFF;
buf[9] = (name.length >> 8) & 0xFF;
var k = 10;
for ( var i = 0; i < name.length; i++) {
buf[k++] = name.charCodeAt(i);
}
this.pending[this.next_id] = new PendingData( return_cb, data);
if ( this.debug) console.log( "Sending getObjectFromName", this.next_id, name);
this.ws.send(buf);
this.next_id++;
};
this.crrSignal = function( oid, return_cb, data) {
var buf = new Uint8Array(14); var buf = new Uint8Array(14);
buf[0] = Msg.CRR_SIGNAL; buf[0] = Msg.CRR_SIGNAL;
buf[2] = this.next_id & 0xFF; buf[2] = this.next_id & 0xFF;
...@@ -1839,13 +2136,13 @@ function Gdh() { ...@@ -1839,13 +2136,13 @@ function Gdh() {
buf[11] = (oid.oix >> 8) & 0xFF; buf[11] = (oid.oix >> 8) & 0xFF;
buf[12] = (oid.oix >> 16) & 0xFF; buf[12] = (oid.oix >> 16) & 0xFF;
buf[13] = (oid.oix >> 24) & 0xFF; buf[13] = (oid.oix >> 24) & 0xFF;
this.pending[this.next_id] = new PendingData(return_cb, data); this.pending[this.next_id] = new PendingData( return_cb, data);
if (this.debug) console.log("Sending crrObject", this.next_id, oid.vid, oid.oix); if ( this.debug) console.log( "Sending crrObject", this.next_id, oid.vid, oid.oix);
this.ws.send(buf); this.ws.send(buf);
this.next_id++; this.next_id++;
}; };
this.getOpwindMenu = function (name, return_cb, data) { this.getOpwindMenu = function( name, return_cb, data) {
var len = name.length; var len = name.length;
var buf = new Uint8Array(8 + name.length); var buf = new Uint8Array(8 + name.length);
...@@ -1857,16 +2154,17 @@ function Gdh() { ...@@ -1857,16 +2154,17 @@ function Gdh() {
buf[6] = name.length & 0xFF; buf[6] = name.length & 0xFF;
buf[7] = (name.length >> 8) & 0xFF; buf[7] = (name.length >> 8) & 0xFF;
var k = 8; var k = 8;
for (var i = 0; i < name.length; i++) { for ( var i = 0; i < name.length; i++) {
buf[k++] = name.charCodeAt(i); buf[k++] = name.charCodeAt(i);
} }
this.pending[this.next_id] = new PendingData(return_cb, data); this.pending[this.next_id] = new PendingData( return_cb, data);
if (this.debug) console.log("Sending getOpwindMenu", this.next_id); if ( this.debug) console.log( "Sending getOpwindMenu", this.next_id);
this.ws.send(buf); this.ws.send(buf);
this.next_id++; this.next_id++;
}; };
this.login = function (user, passwd, return_cb, data) { this.login = function( user, passwd, return_cb, data) {
var buf = new Uint8Array(6 + 2 + user.length + 2 + passwd.length); var buf = new Uint8Array(6 + 2 + user.length + 2 + passwd.length);
buf[0] = Msg.CHECK_USER; buf[0] = Msg.CHECK_USER;
buf[2] = this.next_id & 0xFF; buf[2] = this.next_id & 0xFF;
...@@ -1875,23 +2173,85 @@ function Gdh() { ...@@ -1875,23 +2173,85 @@ function Gdh() {
buf[5] = (this.next_id >> 24) & 0xFF; buf[5] = (this.next_id >> 24) & 0xFF;
var k = 6; var k = 6;
buf[k] = user.length & 0xFF; buf[k] = user.length & 0xFF;
buf[k + 1] = (user.length >> 8) & 0xFF; buf[k+1] = (user.length >> 8) & 0xFF;
k += 2; k += 2;
for (var i = 0; i < user.length; i++) { for ( var i = 0; i < user.length; i++) {
buf[k++] = user.charCodeAt(i); buf[k++] = user.charCodeAt(i);
} }
buf[k] = passwd.length & 0xFF; buf[k] = passwd.length & 0xFF;
buf[k + 1] = (passwd.length >> 8) & 0xFF; buf[k+1] = (passwd.length >> 8) & 0xFF;
k += 2; k += 2;
for (var i = 0; i < passwd.length; i++) { for ( var i = 0; i < passwd.length; i++) {
buf[k++] = passwd.charCodeAt(i); buf[k++] = passwd.charCodeAt(i);
} }
this.pending[this.next_id] = new PendingData(return_cb, data); this.pending[this.next_id] = new PendingData( return_cb, data);
if (this.debug) console.log("Sending login", this.next_id); if ( this.debug) console.log( "Sending login", this.next_id);
this.ws.send(buf); this.ws.send(buf);
this.next_id++; this.next_id++;
}; };
this.getMsg = function( value, return_cb, data) {
var buf = new Uint8Array(10);
buf[0] = Msg.GET_MSG;
buf[2] = this.next_id & 0xFF;
buf[3] = (this.next_id >> 8) & 0xFF;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
buf[6] = value & 0xFF;
buf[7] = (value >> 8) & 0xFF;
buf[8] = (value >> 16) & 0xFF;
buf[9] = (value >> 24) & 0xFF;
this.pending[this.next_id] = new PendingData( return_cb, data);
this.ws.send(buf);
if ( this.debug) console.log("Sending getMsg", this.next_id, value);
this.next_id++;
};
this.mhSync = function( sync, return_cb, data) {
var buf = new Uint8Array(10);
buf[0] = Msg.MH_SYNC;
buf[2] = this.next_id & 0xFF;
buf[3] = (this.next_id >> 8) & 0xFF;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
buf[6] = sync & 0xFF;
buf[7] = (sync >> 8) & 0xFF;
buf[8] = (sync >> 16) & 0xFF;
buf[9] = (sync >> 24) & 0xFF;
this.pending[this.next_id] = new PendingData( return_cb, data);
if ( this.debug) console.log( "Sending mhSync", this.next_id);
this.ws.send(buf);
this.next_id++;
};
this.mhAcknowledge = function( event_id, return_cb, data) {
var buf = new Uint8Array(16 + event_id.birthTime.length);
buf[0] = Msg.MH_ACK;
buf[2] = this.next_id & 0xFF;
buf[3] = (this.next_id >> 8) & 0xFF;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
buf[6] = event_id.nix & 0xFF;
buf[7] = (event_id.nix >> 8) & 0xFF;
buf[8] = (event_id.nix >> 16) & 0xFF;
buf[9] = (event_id.nix >> 24) & 0xFF;
buf[10] = event_id.idx & 0xFF;
buf[11] = (event_id.idx >> 8) & 0xFF;
buf[12] = (event_id.idx >> 16) & 0xFF;
buf[13] = (event_id.idx >> 24) & 0xFF;
var k = 14;
buf[k] = event_id.birthTime.length & 0xFF;
buf[k+1] = (event_id.birthTime.length >> 8) & 0xFF;
k += 2;
for ( var i = 0; i < event_id.birthTime.length; i++) {
buf[k++] = event_id.birthTime.charCodeAt(i);
}
this.pending[this.next_id] = new PendingData( return_cb, data);
if ( this.debug) console.log( "Sending mhAcknowledge", this.next_id);
console.log( "Sending mhAcknowledge", this.next_id);
this.ws.send(buf);
this.next_id++;
};
} }
/** End Gdh **/ /** End Gdh **/
...@@ -1907,9 +2267,9 @@ function OpWindMenu() { ...@@ -1907,9 +2267,9 @@ function OpWindMenu() {
var self = this; var self = this;
this.init = function () { this.init = function() {
this.host = window.location.hostname; this.host = window.location.hostname;
if (this.host === "") if ( this.host == "")
this.host = "localhost"; this.host = "localhost";
this.gdh = new Gdh(); this.gdh = new Gdh();
...@@ -1917,11 +2277,11 @@ function OpWindMenu() { ...@@ -1917,11 +2277,11 @@ function OpWindMenu() {
this.gdh.init(); this.gdh.init();
}; };
this.is_authorized = function (access) { this.is_authorized = function( access) {
return !!(this.priv & access); return ( this.priv & access) ? true : false;
}; }
this.get_opplace = function () { this.get_opplace = function() {
var query = window.location.search.substring(1); var query = window.location.search.substring(1);
console.log("query", query); console.log("query", query);
...@@ -1930,120 +2290,138 @@ function OpWindMenu() { ...@@ -1930,120 +2290,138 @@ function OpWindMenu() {
return vars[0].substring(8); return vars[0].substring(8);
}; };
this.gdh_init_cb = function () { this.gdh_init_cb = function() {
var oid = new PwrtObjid(0, 0); var oid = new PwrtObjid( 0, 0);
self.user = "Default"; self.user = "Default";
self.gdh.login("", "", self.login_cb, self); self.gdh.login( "", "", self.login_cb, self);
self.gdh.getOpwindMenu(self.get_opplace(), self.get_menu_cb, 999); self.gdh.getOpwindMenu( self.get_opplace(), self.get_menu_cb, 999);
}; };
this.add_menu_button = function (context, text) { this.add_menu_button = function( context, text) {
var button = document.createElement("input"); var button = document.createElement( "input");
button.type = "button"; button.type = "button";
button.className = "leftmenu-button"; button.className = "leftmenu-button";
button.value = text; button.value = text;
button.addEventListener('click', new Function("menu.button_cb(\"" + button.value + "\")")); button.addEventListener( 'click', new Function( "menu.button_cb(\"" + button.value + "\")"));
context.appendChild(button); context.appendChild( button);
context.appendChild(document.createElement("br")); context.appendChild( document.createElement( "br"));
return button; return button;
}; };
this.get_menu_cb = function (id, data, sts, result) { this.get_menu_cb = function( id, data, sts, result) {
self.info = result; self.info = result;
console.log("Menu received", sts, data, result.buttons.length); console.log( "Menu received", sts, data, result.buttons.length);
var context = document.getElementById("opwindmenu"); var context = document.getElementById("opwindmenu");
document.getElementById("opwind_title").innerHTML = result.title; document.getElementById("opwind_title").innerHTML = result.title;
document.getElementById("opwind_text").innerHTML = result.text; document.getElementById("opwind_text").innerHTML = result.text;
if (result.enable_login) { if ( result.enable_login) {
self.user_text = document.createTextNode(self.user + " on " + self.host); self.user_text = document.createTextNode( self.user + " on " + self.host);
context.appendChild(self.user_text); context.appendChild( self.user_text);
context.appendChild(document.createElement("hr")); context.appendChild( document.createElement( "hr"));
document.getElementById("login_button").addEventListener("click", function (event) { document.getElementById("login_button").addEventListener( "click", function( event) {
if (document.getElementById("login_frame").style.visibility === 'hidden') { if ( document.getElementById("login_frame").style.visibility == 'hidden') {
document.getElementById("login_user").value = ""; document.getElementById("login_user").value = "";
document.getElementById("login_passw").value = ""; document.getElementById("login_passw").value = "";
document.getElementById("login_frame").style.visibility = 'visible'; document.getElementById("login_frame").style.visibility='visible';
document.getElementById("login_frame").style.height = '120px'; document.getElementById("login_frame").style.height='120px';
document.getElementById("login_user").focus(); document.getElementById("login_user").focus();
} else { }
document.getElementById("login_frame").style.visibility = 'hidden'; else {
document.getElementById("login_frame").style.height = '0px'; document.getElementById("login_frame").style.visibility='hidden';
document.getElementById("login_frame").style.height='0px';
} }
}); });
document.getElementById("apply_button").addEventListener("click", function (event) { document.getElementById("apply_button").addEventListener( "click", function( event) {
var user = document.getElementById("login_user").value; var user = document.getElementById("login_user").value;
var passwd = document.getElementById("login_passw").value; var passwd = document.getElementById("login_passw").value;
if (user.trim() === "") if ( user.trim() == "")
return; return;
document.getElementById("login_frame").style.visibility = 'hidden'; document.getElementById("login_frame").style.visibility='hidden';
document.getElementById("login_frame").style.height = '0px'; document.getElementById("login_frame").style.height='0px';
var c = new JopCrypt(); var c = new JopCrypt();
passwd = c.crypt("aa", passwd); passwd = c.crypt( "aa", passwd);
self.user = user; self.user = user;
self.gdh.login(user, passwd, self.login_cb, self); self.gdh.login( user, passwd, self.login_cb, self);
}); });
document.getElementById("cancel_button").addEventListener("click", function (event) { document.getElementById("cancel_button").addEventListener( "click", function( event) {
document.getElementById("login_frame").style.visibility = 'hidden'; document.getElementById("login_frame").style.visibility='hidden';
document.getElementById("login_frame").style.height = '0px'; document.getElementById("login_frame").style.height='0px';
}); });
document.getElementById("logout_button").addEventListener("click", function (event) { document.getElementById("logout_button").addEventListener( "click", function( event) {
document.getElementById("login_frame").style.visibility = 'hidden'; document.getElementById("login_frame").style.visibility='hidden';
document.getElementById("login_frame").style.height = '0px'; document.getElementById("login_frame").style.height='0px';
self.priv = 0; self.priv = 0;
self.user = "Default"; self.user = "Default";
self.gdh.login("", "", self.login_cb, self); self.gdh.login( "", "", self.login_cb, self);
}); });
document.getElementById("login_user").value = ""; document.getElementById("login_user").value = "";
document.getElementById("login_passw").value = ""; document.getElementById("login_passw").value = "";
//document.getElementById("login_frame").setAttribute("style", "visibility:hidden;height:10px"; //document.getElementById("login_frame").setAttribute("style", "visibility:hidden;height:10px";
document.getElementById("login_frame").style.visibility = 'hidden'; document.getElementById("login_frame").style.visibility='hidden';
document.getElementById("login_frame").style.height = '0px'; document.getElementById("login_frame").style.height='0px';
} else { }
else {
document.getElementById("login_button").remove(); document.getElementById("login_button").remove();
document.getElementById("login_frame").remove(); document.getElementById("login_frame").remove();
} }
if (result.enable_language) if ( result.enable_language)
self.add_menu_button(context, "Language"); self.add_menu_button( context, "Language");
if (result.enable_alarmlist) if ( result.enable_alarmlist) {
self.add_menu_button(context, "AlarmList"); self.add_menu_button( context, "AlarmList");
if (result.enable_eventlog) self.add_menu_button( context, "EventList");
self.add_menu_button(context, "EventLog"); }
if (result.enable_navigator) if ( result.enable_eventlog)
self.add_menu_button(context, "Navigator"); self.add_menu_button( context, "EventLog");
if (!result.disable_help) if ( result.enable_navigator)
self.add_menu_button(context, "Help"); self.add_menu_button( context, "Navigator");
if (!result.disable_proview) if ( !result.disable_help)
self.add_menu_button(context, "ProviewR"); self.add_menu_button( context, "Help");
if ( !result.disable_proview)
context.appendChild(document.createElement("hr")); self.add_menu_button( context, "ProviewR");
context.appendChild( document.createElement( "hr"));
var button; var button;
for (var i = 0; i < result.buttons.length; i++) { for ( var i = 0; i < result.buttons.length; i++) {
self.add_menu_button(context, result.buttons[i].text); self.add_menu_button( context, result.buttons[i].text);
} }
}; };
this.button_cb = function (text) { this.button_cb = function( text) {
if (self.info.enable_language && text === "Language") {
if ( self.info.enable_language && text == "Language") {
console.log("Language activated"); console.log("Language activated");
} else if (self.info.enable_alarmlist && text === "AlarmList") { }
else if ( self.info.enable_alarmlist && text == "AlarmList") {
console.log("AlarmList activated"); console.log("AlarmList activated");
if (!(self.is_authorized(Pwr.mAccess_RtRead | Pwr.mAccess_RtWrite | if ( !(self.is_authorized( Pwr.mAccess_RtRead | Pwr.mAccess_RtWrite |
Pwr.mAccess_AllOperators | Pwr.mAccess_AllOperators |
Pwr.mAccess_System | Pwr.mAccess_Maintenance | Pwr.mAccess_System | Pwr.mAccess_Maintenance |
Pwr.mAccess_Process | Pwr.mAccess_Instrument))) Pwr.mAccess_Process | Pwr.mAccess_Instrument)))
window.alert("Not authorized for this operation"); window.alert("Not authorized for this operation");
else else
window.alert("Not yet implemented"); window.open( "ev.html?list=alarm", "_blank");
} else if (self.info.enable_eventlog && text === "EventLog") { }
else if ( self.info.enable_alarmlist && text == "EventList") {
console.log("EventList activated");
if ( !(self.is_authorized( Pwr.mAccess_RtRead | Pwr.mAccess_RtWrite |
Pwr.mAccess_AllOperators |
Pwr.mAccess_System | Pwr.mAccess_Maintenance |
Pwr.mAccess_Process | Pwr.mAccess_Instrument)))
window.alert("Not authorized for this operation");
else
window.open( "ev.html?list=event", "_blank");
}
else if ( self.info.enable_eventlog && text == "EventLog") {
console.log("EventLog activated"); console.log("EventLog activated");
if (!(self.is_authorized(Pwr.mAccess_RtRead | Pwr.mAccess_RtWrite | if ( !(self.is_authorized( Pwr.mAccess_RtRead | Pwr.mAccess_RtWrite |
Pwr.mAccess_AllOperators | Pwr.mAccess_AllOperators |
Pwr.mAccess_System | Pwr.mAccess_Maintenance | Pwr.mAccess_System | Pwr.mAccess_Maintenance |
Pwr.mAccess_Process | Pwr.mAccess_Instrument))) Pwr.mAccess_Process | Pwr.mAccess_Instrument)))
...@@ -2051,37 +2429,41 @@ function OpWindMenu() { ...@@ -2051,37 +2429,41 @@ function OpWindMenu() {
window.alert("Not authorized for this operation"); window.alert("Not authorized for this operation");
else else
window.alert("Not yet implemented"); window.alert("Not yet implemented");
} else if (self.info.enable_navigator && text === "Navigator") { }
else if ( self.info.enable_navigator && text == "Navigator") {
console.log("Navigator activated"); console.log("Navigator activated");
if (!(self.is_authorized(Pwr.mAccess_RtNavigator | if ( !(self.is_authorized( Pwr.mAccess_RtNavigator |
Pwr.mAccess_System | Pwr.mAccess_Maintenance | Pwr.mAccess_System | Pwr.mAccess_Maintenance |
Pwr.mAccess_Process | Pwr.mAccess_Instrument))) Pwr.mAccess_Process | Pwr.mAccess_Instrument)))
window.alert("Not authorized for this operation"); window.alert("Not authorized for this operation");
else else
window.open("xtt.html", "_blank"); window.open( "xtt.html", "_blank");
} else if (!self.info.disable_help && text === "Help") { }
else if ( !self.info.disable_help && text == "Help") {
console.log("Help activated"); console.log("Help activated");
window.open("xtt_help_index.html", "_blank"); window.open( "xtt_help_index.html", "_blank");
} else if (!self.info.disable_proview && text === "ProviewR") { }
else if ( !self.info.disable_proview && text == "ProviewR") {
console.log("ProviewR activated"); console.log("ProviewR activated");
window.open("http://www.proview.se", "_blank"); window.open( "http://www.proview.se", "_blank");
} else { }
if (!(self.is_authorized(Pwr.mAccess_RtRead | Pwr.mAccess_RtWrite | else {
if ( !(self.is_authorized( Pwr.mAccess_RtRead | Pwr.mAccess_RtWrite |
Pwr.mAccess_AllOperators | Pwr.mAccess_AllOperators |
Pwr.mAccess_System | Pwr.mAccess_Maintenance | Pwr.mAccess_System | Pwr.mAccess_Maintenance |
Pwr.mAccess_Process | Pwr.mAccess_Instrument))) Pwr.mAccess_Process | Pwr.mAccess_Instrument)))
window.alert("Not authorized for this operation"); window.alert("Not authorized for this operation");
else { else {
for (var i = 0; i < self.info.buttons.length; i++) { for ( var i = 0; i < self.info.buttons.length; i++) {
if (self.info.buttons[i].text === text) { if ( self.info.buttons[i].text == text) {
console.log("Found", self.info.buttons[i].text); console.log("Found", self.info.buttons[i].text);
var name = self.info.buttons[i].name; var name = self.info.buttons[i].name;
var n = name.indexOf(".pwg"); var n = name.indexOf(".pwg");
if (n !== -1) if ( n != -1)
name = name.substring(0, n); name = name.substring(0,n);
var url = "ge.html?graph=" + name; var url = "ge.html?graph=" + name;
console.log("url", url); console.log("url", url);
window.open(url, "_blank"); window.open( url, "_blank");
break; break;
} }
} }
...@@ -2089,27 +2471,30 @@ function OpWindMenu() { ...@@ -2089,27 +2471,30 @@ function OpWindMenu() {
} }
}; };
this.login_cb = function (id, data, sts, result) { this.login_cb = function( id, data, sts, result) {
console.log("Login:", sts, result); console.log( "Login:", sts, result);
if (sts & 1) { if ( sts & 1) {
self.priv = result; self.priv = result;
sessionStorage.setItem("pwr_privilege", self.priv); sessionStorage.setItem("pwr_privilege", self.priv);
if (self.user_text != null) if ( self.user_text != null)
self.user_text.textContent = self.user + " on " + self.host; self.user_text.textContent = self.user + " on " + self.host;
console.log("Login", self.user, "Priv", self.priv); console.log( "Login", self.user, "Priv", self.priv);
} else { }
else {
self.priv = 0; self.priv = 0;
self.user = "none"; self.user = "none";
sessionStorage.setItem("pwr_privilege", self.priv); sessionStorage.setItem("pwr_privilege", self.priv);
if (self.user_text != null) if ( self.user_text != null)
self.user_text.textContent = "None on " + self.host; self.user_text.textContent = "None on " + self.host;
console.log("Login failure", "Priv", self.priv); console.log( "Login failure", "Priv", self.priv);
} }
}; };
} }
var menu = new OpWindMenu(); var menu = new OpWindMenu();
menu.init(); menu.init();
/** End OpWind **/ /** End OpWind **/
...@@ -8,12 +8,13 @@ ...@@ -8,12 +8,13 @@
<body> <body>
<div class="toolbar" role="toolbar"> <div class="toolbar" role="toolbar">
<div id="toolitem1" tabindex="0" class="toolbar-item" role="button"><img src="toolbar_graph.png"><img></div> <div id="toolitem1" tabindex="0" class="toolbar-item" role="button"><img src="toolbar_graph.png"><img></div>
<div id="toolitem2" tabindex="-1" class="toolbar-item" role="button"><img src="toolbar_plc.png"><img></div> <div id="toolitem2" tabindex="-1" class="toolbar-item" role="button"><img src="toolbar_objectgraph.png"><img></div>
<div id="toolitem3" tabindex="-1" class="toolbar-item" role="button"><img src="toolbar_history.png"><img></div> <div id="toolitem3" tabindex="-1" class="toolbar-item" role="button"><img src="toolbar_plc.png"><img></div>
<div id="toolitem4" tabindex="-1" class="toolbar-item" role="button"><img src="toolbar_object.png"><img></div> <div id="toolitem4" tabindex="-1" class="toolbar-item" role="button"><img src="toolbar_history.png"><img></div>
<div id="toolitem5" tabindex="-1" class="toolbar-item" role="button"><img src="toolbar_crossref.png"><img></div> <div id="toolitem5" tabindex="-1" class="toolbar-item" role="button"><img src="toolbar_object.png"><img></div>
<div id="toolitem6" tabindex="-1" class="toolbar-item" role="button"><img src="toolbar_help.png"><img></div> <div id="toolitem6" tabindex="-1" class="toolbar-item" role="button"><img src="toolbar_crossref.png"><img></div>
<div id="toolitem7" tabindex="-1" class="toolbar-item" role="button"><img src="toolbar_classhelp.png"><img></div> <div id="toolitem7" tabindex="-1" class="toolbar-item" role="button"><img src="toolbar_help.png"><img></div>
<div id="toolitem8" tabindex="-1" class="toolbar-item" role="button"><img src="toolbar_classhelp.png"><img></div>
</div> </div>
<!-- <div style="height:300px;overflow:auto;"> --> <!-- <div style="height:300px;overflow:auto;"> -->
<canvas id="flowcanvas" width="1200" height="800"></canvas> <canvas id="flowcanvas" width="1200" height="800"></canvas>
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -295,6 +295,12 @@ pwr_tStatus mh_OutunitConnect( ...@@ -295,6 +295,12 @@ pwr_tStatus mh_OutunitConnect(
l.pSelEventType = &((pwr_sClass_WebHandler*)p)->EventSelectType; l.pSelEventType = &((pwr_sClass_WebHandler*)p)->EventSelectType;
l.SelectListIsUpdated = NULL; l.SelectListIsUpdated = NULL;
break; break;
case pwr_cClass_WebSocketServer:
type = mh_eOutunitType_Operator;
l.pSelL = (void*)&((pwr_sClass_WebSocketServer*)p)->EventSelectList[0];
l.pSelEventType = &((pwr_sClass_WebSocketServer*)p)->EventSelectType;
l.SelectListIsUpdated = NULL;
break;
case pwr_cClass_RttConfig: case pwr_cClass_RttConfig:
type = mh_eOutunitType_Operator; type = mh_eOutunitType_Operator;
l.pSelL = (void*)&((pwr_sClass_RttConfig*)p)->EventSelectList[0]; l.pSelL = (void*)&((pwr_sClass_RttConfig*)p)->EventSelectList[0];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment