Commit f4585c02 authored by Claes Sjofors's avatar Claes Sjofors

User object removed, and integrated with WebHandler object

parent cc6b8836
...@@ -129,39 +129,29 @@ public class MhServer ...@@ -129,39 +129,29 @@ public class MhServer
maxConnections = 50; maxConnections = 50;
return 1; return 1;
} }
CdhrObjid cdhrObjid;
CdhrString cdhrString; CdhrString cdhrString;
CdhrString cdhrStringUser;
CdhrInt cdhrMaxCon; CdhrInt cdhrMaxCon;
CdhrInt cdhrMaxAlarms; CdhrInt cdhrMaxAlarms;
CdhrInt cdhrMaxEvents; CdhrInt cdhrMaxEvents;
cdhrObjid = gdh.getClassList(Pwrb.cClass_WebHandler); cdhrWebHandlerObj = gdh.getClassList(Pwrb.cClass_WebHandler);
if(cdhrObjid.evenSts()) if(cdhrWebHandlerObj.evenSts())
{ {
errh.info("No WebHandler is configured, GdhServer terminating"); errh.info("No WebHandler is configured, MhServer terminating");
return cdhrObjid.getSts(); return cdhrWebHandlerObj.getSts();
} }
cdhrString = gdh.objidToName(cdhrObjid.objid, Cdh.mName_volumeStrict); cdhrString = gdh.objidToName(cdhrWebHandlerObj.objid, Cdh.mName_volumeStrict);
if(cdhrString.evenSts()) if(cdhrString.evenSts())
{ {
return cdhrString.getSts(); return cdhrString.getSts();
} }
String userObjectString = cdhrString.str + ".UserObject"; String maxAlarmsAttr = cdhrString.str + ".MaxNoOfAlarms";
cdhrStringUser = gdh.getObjectInfoString(userObjectString); String maxEventsAttr = cdhrString.str + ".MaxNoOfEvents";
cdhrUserObj = gdh.nameToObjid(cdhrStringUser.str);
if(cdhrUserObj.evenSts())
{
return cdhrUserObj.getSts();
}
String maxAlarmsAttr = cdhrStringUser.str + ".MaxNoOfAlarms";
String maxEventsAttr = cdhrStringUser.str + ".MaxNoOfEvents";
String maxConAttr = cdhrString.str + ".MaxConnections"; String maxConAttr = cdhrString.str + ".MaxConnections";
cdhrMaxAlarms = gdh.getObjectInfoInt(maxAlarmsAttr); cdhrMaxAlarms = gdh.getObjectInfoInt(maxAlarmsAttr);
cdhrMaxEvents = gdh.getObjectInfoInt(maxEventsAttr); cdhrMaxEvents = gdh.getObjectInfoInt(maxEventsAttr);
cdhrMaxCon = gdh.getObjectInfoInt(maxConAttr); cdhrMaxCon = gdh.getObjectInfoInt(maxConAttr);
System.out.println( "MaxNoOfAlarms: " + cdhrStringUser.str + " " + cdhrMaxAlarms.value + " " + cdhrMaxAlarms.evenSts()); System.out.println( "MaxNoOfAlarms: " + cdhrString.str + " " + cdhrMaxAlarms.value + " " + cdhrMaxAlarms.evenSts());
if(cdhrMaxCon.evenSts()) if(cdhrMaxCon.evenSts())
{ {
return cdhrMaxCon.getSts(); return cdhrMaxCon.getSts();
...@@ -204,7 +194,7 @@ public class MhServer ...@@ -204,7 +194,7 @@ public class MhServer
} }
} }
CdhrObjid cdhrUserObj; CdhrObjid cdhrWebHandlerObj;
/** /**
...@@ -244,7 +234,7 @@ public class MhServer ...@@ -244,7 +234,7 @@ public class MhServer
mhThread = new MhThread[maxConnections]; mhThread = new MhThread[maxConnections];
mhData = new MhData(maxAlarms, maxEvents); mhData = new MhData(maxAlarms, maxEvents);
PwrtStatus stsM = mh.outunitConnect(cdhrUserObj.objid); PwrtStatus stsM = mh.outunitConnect(cdhrWebHandlerObj.objid);
if(stsM.evenSts()) if(stsM.evenSts())
{ {
System.out.println("Fel vid outunitConnect"); System.out.println("Fel vid outunitConnect");
......
/*
* Proview $Id: wb_c_rttconfig.cpp,v 1.1 2007-01-04 07:29:03 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**/
/* wb_c_rttconfig.c -- work bench methods of the RttConfig class. */
#include "wb_pwrs.h"
#include "wb_pwrs_msg.h"
#include "wb_ldh.h"
static pwr_tStatus PostCreate (
ldh_tSesContext Session,
pwr_tOid Object,
pwr_tOid Father,
pwr_tCid Class
) {
pwr_tOid oid;
pwr_tCid cid;
pwr_tStatus sts;
pwr_tInt32 *number;
pwr_tInt32 max_number = 0;
int size;
sts = ldh_ClassNameToId(Session, &cid, "OpPlace");
if ( EVEN(sts)) return sts;
// Get next OpNumber
sts = ldh_GetClassList(Session, cid, &oid);
while ( ODD(sts)) {
sts = ldh_GetObjectPar(Session, oid, "RtBody", "OpNumber", (char **)&number,
&size);
if ( EVEN(sts)) return sts;
if ( *number > max_number)
max_number = *number;
free( (char *) number);
sts = ldh_GetNextObject(Session, oid, &oid);
}
sts = ldh_ClassNameToId(Session, &cid, "User");
if ( EVEN(sts)) return sts;
sts = ldh_GetClassList(Session, cid, &oid);
while ( ODD(sts)) {
sts = ldh_GetObjectPar(Session, oid, "RtBody", "OpNumber", (char **)&number,
&size);
if ( EVEN(sts)) return sts;
if ( *number > max_number)
max_number = *number;
free( (char *) number);
sts = ldh_GetNextObject(Session, oid, &oid);
}
max_number++;
sts = ldh_CreateObject(Session, &oid, "User", cid, Object, ldh_eDest_IntoLast);
if ( EVEN(sts)) return sts;
sts = ldh_SetObjectPar(Session, oid, "RtBody", "OpNumber", (char *)&max_number,
sizeof(max_number));
if ( EVEN(sts)) return sts;
sts = ldh_SetObjectPar(Session, Object, "RtBody", "UserObject", (char *)&oid,
sizeof(oid));
if ( EVEN(sts)) return sts;
return PWRS__SUCCESS;
}
pwr_dExport pwr_BindMethods(RttConfig) = {
pwr_BindMethod(PostCreate),
pwr_NullMethod
};
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