Commit 214a53b4 authored by claes's avatar claes

ExternVolume in runtime implemented

parent f3f77392
/*
* Proview $Id: rt_neth.c,v 1.13 2006-03-20 06:42:21 claes Exp $
* Proview $Id: rt_neth.c,v 1.14 2006-09-14 14:16:07 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -81,6 +81,7 @@ static void sendVolumesR (gdb_sNode*, net_sVolumes*, unsigned int);
static void volumes (qcom_sGet*);
static void volumesR (qcom_sGet*);
static void volumes7 (qcom_sGet*);
static void serverConnect (qcom_sGet*);
#if 0
static void linkEvent (pwr_tUInt32, net_eEvent);
static void sendIdAck (gdb_sNode*);
......@@ -121,6 +122,7 @@ static char *cMsg[net_eMsg_end] = {
"getCclassR",
"getGclass",
"getGclassR",
"serverConnect",
"net_eMsg_",
"volumes7"
};
......@@ -155,6 +157,7 @@ static void (*fromApplication[net_eMsg_end])(qcom_sGet *) = {
bugError, /* net_eMsg_GetCclassR will never reach neth */
cmvolsm_GetGclass,
bugError, /* net_eMsg_GetGclassR will never reach neth */
serverConnect, /* net_eMsg_serverConnect */
bugError, /* net_eMsg_ */
volumes7
};
......@@ -454,7 +457,7 @@ id (
cMsg[get->type.s], cdh_NodeIdToString(NULL, mp->hdr.nid, 0, 0));
}
if (get->sender.nid == gdbroot->my_qid.nid ) {
if (get->sender.nid == gdbroot->my_qid.nid && mp->hdr.nid == gdbroot->db->nid) {
errh_Error("New node using nid %s, conflicts with local node, '%s' ignored",
cdh_NodeIdToString(NULL, mp->hdr.nid, 0, 0),
cMsg[get->type.s]);
......@@ -513,6 +516,7 @@ id (
np->nod_oid = mp->node.nod_oid;
np->netver = mp->node.netver;
np->cclassSupport = cclassSupport;
np->handler = mp->node.handler;
} gdb_ScopeUnlock;
......@@ -655,6 +659,24 @@ linkDisconnect (
np->flags.b.active = 0;
}
gdb_sNode *snp;
pool_sQlink *nl;
// Disconnect any server on this node
for ( nl = pool_Qsucc(NULL, gdbroot->pool, &gdbroot->db->nod_lh);
nl != &gdbroot->db->nod_lh;
nl = pool_Qsucc(NULL, gdbroot->pool, nl)) {
snp = pool_Qitem(nl, gdb_sNode, nod_ll);
if ( snp != np && np->nid == gdb_SnidToQnid( snp->nid)) {
flushNode(snp);
snp->flags.b.connected = 0;
snp->flags.b.active = 0;
}
}
}
......@@ -834,8 +856,7 @@ sendFlush (
np->name, cdh_NodeIdToString(NULL, np->nid, 0, 0));
}
tgt.nid = np->nid;
tgt.qix = net_cProcHandler;
tgt = np->handler;
size = sizeof(msg);
......@@ -845,7 +866,7 @@ sendFlush (
msg.node.nod_oid = gdbroot->my_node->nod_oid;
msg.node.vol_oid = gdbroot->my_node->vol_oid;
net_Put(&sts, &tgt, &msg, net_eMsg_flush, 0, size);
net_Put(&sts, &tgt, &msg, net_eMsg_flush, 0, size, 0);
if (EVEN(sts))
errh_Error("Sending 'flush' to %s (%s)\n%m",
np->name, cdh_NodeIdToString(NULL, np->nid, 0, 0), sts);
......@@ -869,8 +890,12 @@ sendId (
np->name, cdh_NodeIdToString(NULL, np->nid, 0, 0));
}
tgt.nid = np->nid;
tgt.qix = net_cProcHandler;
if ( np->handler.nid)
tgt = np->handler;
else {
tgt.nid = np->nid;
tgt.qix = net_cProcHandler;
}
size = sizeof(msg);
......@@ -880,7 +905,7 @@ sendId (
msg.node.nod_oid = gdbroot->my_node->nod_oid;
msg.node.vol_oid = gdbroot->my_node->vol_oid;
net_Put(&sts, &tgt, &msg, net_eMsg_id, 0, size);
net_Put(&sts, &tgt, &msg, net_eMsg_id, 0, size, 0);
if (EVEN(sts))
errh_Error("Sending 'id' to %s (%s)\n%m",
np->name, cdh_NodeIdToString(NULL, np->nid, 0, 0), sts);
......@@ -983,15 +1008,14 @@ sendVolumes (
return;
}
tgt.nid = np->nid;
tgt.qix = net_cProcHandler;
tgt = np->handler;
if (!cclassSupport)
msgtype = net_eMsg_volumes7;
else
msgtype = net_eMsg_volumes;
if (!net_Put(&sts, &tgt, mp, msgtype, 0, size))
if (!net_Put(&sts, &tgt, mp, msgtype, 0, size, 0))
errh_Error("Sending 'volumes' to %s (%s)\n%m",
np->name, cdh_NodeIdToString(NULL, np->nid, 0, 0), sts);
......@@ -1036,10 +1060,9 @@ sendVolumesR (
mp->count = j;
mp->ctx = vmp->ctx;
tgt.nid = np->nid;
tgt.qix = net_cProcHandler;
tgt = np->handler;
if (!net_Put(&sts, &tgt, mp, net_eMsg_volumesR, 0, size)) {
if (!net_Put(&sts, &tgt, mp, net_eMsg_volumesR, 0, size, 0)) {
errh_Error("Sending 'volumesR' to %s (%s)\n%m",
np->name, cdh_NodeIdToString(NULL, (pwr_tNodeId)np->nid, 0, 0), sts);
}
......@@ -1062,6 +1085,9 @@ volumes (
gdb_sNode *np;
pwr_tUInt32 nid = get->sender.nid;
if ( vmp->count)
nid = vmp->g[0].nid;
gdb_ScopeLock {
np = hash_Search(&sts, gdbroot->nid_ht, &nid);
......@@ -1353,8 +1379,7 @@ sendIdAck (
np->name, cdh_NodeIdToString(NULL, np->nid, 0, 0));
}
tgt.nid = np->nid;
tgt.qix = net_cProcHandler;
tgt np->handler;
gdb_ScopeLock {
......@@ -1366,7 +1391,7 @@ sendIdAck (
} gdb_ScopeUnlock;
if (!net_Put(&sts, &tgt, &msg, net_eMsg_idAck, 0, sizeof(msg)))
if (!net_Put(&sts, &tgt, &msg, net_eMsg_idAck, 0, sizeof(msg), 0))
errh_Error("Sending 'idAck' to %s (%s)\n%m",
np->name, cdh_NodeIdToString(NULL, np->nid, 0, 0), sts);
......@@ -1388,12 +1413,65 @@ sendIdAck2 (
np->name, cdh_NodeIdToString(NULL, np->nid, 0, 0));
}
tgt.nid = np->nid;
tgt.qix = net_cProcHandler;
tgt = np->handler;
if (!net_Put(&sts, &tgt, &msg, net_eMsg_idAck2, 0, sizeof(msg)))
if (!net_Put(&sts, &tgt, &msg, net_eMsg_idAck2, 0, sizeof(msg), 0))
errh_Error("Sending 'idAck2' to %s (%s)\n%m",
np->name, cdh_NodeIdToString(NULL, np->nid, 0, 0), sts);
}
#endif
static void
serverConnect (
qcom_sGet *get
)
{
net_sId *mp = get->data;
gdb_sNode *np;
pwr_tStatus sts;
int new_server;
int remote;
gdb_ScopeLock {
np = hash_Search(&sts, gdbroot->nid_ht, &mp->hdr.nid);
if (np == NULL) {
// New server
qcom_sNode node;
pwr_tNodeId nid;
new_server = 1;
for (nid = qcom_cNNid; qcom_NextNode(&sts, &node, nid); nid = node.nid) {
if ( node.nid == get->sender.nid) {
np = gdb_AddNode(&sts, mp->hdr.nid, gdb_mAdd__);
sprintf(np->name, "%s_s%d", node.name, gdb_SnidToSid(mp->hdr.nid));
np->os = node.os;
np->hw = node.hw;
co_SetFormat(&np->fm, node.bo, node.ft);
np->handler = get->reply;
np->flags.b.connected = 1;
// np->flags.b.active = 1;
break;
}
}
}
else {
new_server = 0;
np->flags.b.connected = 1;
// np->flags.b.active = 1;
}
} gdb_ScopeUnlock;
if (np == NULL)
return;
remote = (gdb_SnidToQnid( np->nid) != gdbroot->db->nid);
sendId(np);
if ( remote && !new_server) {
// nodeUp( np);
}
}
include $(pwre_dir_symbols)
-include $(pwre_sroot)/tools/bld/src/$(os_name)/$(hw_name)/$(type_name)_generic.mk
ifeq ($($(type_name)_generic_mk),)
-include $(pwre_sroot)/tools/bld/src/$(os_name)/$(type_name)_generic.mk
endif
ifeq ($($(type_name)_generic_mk),)
include $(pwre_sroot)/tools/bld/src/$(type_name)_generic.mk
endif
-include ../../special.mk
-include ../special.mk
-include special.mk
ifndef link_rule_mk
link_rule_mk := 1
link = $(ldxx) $(linkflags) $(domap) -o $(export_exe) \
$(export_obj) $(objects) $(rt_msg_objs) \
$(pwr_obj)/rt_io_user.o\
-lpwr_rt -lpwr_co \
-lpwr_msg_dummy \
-lrpcsvc -lpthread -lm -lrt
endif
/*
* Proview $Id: rt_pvd_udb.cpp,v 1.1 2006-09-14 14:16:07 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.
*/
#include "pwr.h"
#include "pwr_class.h"
#include "rt_procom.h"
#include "co_provider.h"
#include "rt_gdh_msg.h"
#include "co_pvd_udb.h"
#include "wb_ldh.h"
int main()
{
co_pvd_udb provider( pvd_eEnv_Rt);
rt_procom procom( &provider,
errh_eAnix_appl20, // Application index
"rt_pvd_udb", // Process name
200, // Sid
ldh_cUserDatabaseVolume, // Vid _V254.254.254.246
"VolUserDatabase", // Volume name
0); // Global
procom.init();
procom.mainLoop();
}
/*
* Proview $Id: pwr.h,v 1.24 2006-05-21 22:30:49 lw Exp $
* Proview $Id: pwr.h,v 1.25 2006-09-14 14:16:07 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -238,6 +238,7 @@ typedef unsigned int pwr_tDbId;
typedef pwr_tVolumeId pwr_tNid; //!< Node identity type.
typedef pwr_tNid pwr_tNodeId; //!< Node identity type.
typedef pwr_tNid pwr_tNodeIndex; //!< Node index type.
typedef unsigned int pwr_tSid; //!< Server identity type.
/*_*
@aref refid RefId
......
/*
* Proview $Id: pwr_class.h,v 1.22 2006-05-21 22:30:49 lw Exp $
* Proview $Id: pwr_class.h,v 1.23 2006-09-14 14:16:07 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -1025,10 +1025,11 @@ struct pwr_s_GraphPlcConnection
struct pwr_s_PlantHier
{
pwr_tString80 Description;
pwr_tObjid DefGraph;
pwr_tObjid DefTrend;
pwr_tAttrRef DefGraph;
pwr_tAttrRef DefTrend;
pwr_tString40 HelpTopic;
pwr_tURL DataSheet;
pwr_tURL CircuitDiagram;
pwr_tURL Photo;
};
......
/*
* Proview $Id: wb_pvd_file.h,v 1.2 2005-10-25 12:04:25 claes Exp $
* Proview $Id: co_procom.h,v 1.1 2006-09-14 14:16:07 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -15,20 +15,25 @@
* 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.
**/
*/
#ifndef wb_pvd_file_h
#define wb_pvd_file_h
#ifndef co_procom_h
#define co_procom_h
#include "wb_provider.h"
#include <vector.h>
extern "C" {
#include "rt_errh.h"
}
#include "co_provider.h"
typedef enum {
pitem_mFlags_Deleted = 1 << 0,
pitem_mFlags_Created = 1 << 1
} pitem_mFlags;
procom_obj_mFlags_Deleted = 1 << 0,
procom_obj_mFlags_Created = 1 << 1
} procom_obj_mFlags;
class pitem {
public:
class procom_obj {
public:
int cid;
pwr_tOix oix;
pwr_tOix fthoix;
......@@ -44,11 +49,11 @@ public:
void *userdata;
unsigned int userdata_size;
pitem() : fthoix(0), bwsoix(0), fwsoix(0), fchoix(0), lchoix(0), flags(0),
procom_obj() : fthoix(0), bwsoix(0), fwsoix(0), fchoix(0), lchoix(0), flags(0),
body(0), body_size(0), userdata(0), userdata_size(0)
{ strcpy(lname,"");}
~pitem()
~procom_obj()
{
if ( body)
free(body);
......@@ -56,21 +61,21 @@ public:
free(userdata);
}
pitem( const pitem& x)
procom_obj( const procom_obj& x)
{
memcpy( this, &x, sizeof(pitem));
memcpy( this, &x, sizeof(procom_obj));
if ( x.body) {
body = malloc( body_size);
memcpy( body, x.body, body_size);
}
}
if ( x.userdata) {
userdata = malloc( userdata_size);
memcpy( userdata, x.userdata, userdata_size);
}
}
pitem& operator=(const pitem& x)
procom_obj& operator=(const procom_obj& x)
{
memcpy( this, &x, sizeof(pitem));
memcpy( this, &x, sizeof(procom_obj));
if ( body) {
body = calloc( 1, body_size);
memcpy( body, x.body, body_size);
......@@ -83,38 +88,24 @@ public:
}
};
class co_procom
{
class wb_pvd_file : public wb_provider {
public:
wb_pvd_file() : root(0), next_oix(1) {}
virtual void object( wb_procom *pcom);
virtual void objectOid( wb_procom *pcom, pwr_tOix oix);
virtual void objectName( wb_procom *pcom, char *name);
virtual void objectBody( wb_procom *pcom, pwr_tOix oix);
virtual void createObject( wb_procom *pcom, pwr_tOix destoix, int desttype,
pwr_tCid cid, char *name);
virtual void moveObject( wb_procom *pcom, pwr_tOix oix, pwr_tOix destoix, int desttype);
virtual void copyObject( wb_procom *pcom, pwr_tOix oix, pwr_tOix destoix, int desttype,
char *name);
virtual void deleteObject( wb_procom *pcom, pwr_tOix oix);
virtual void deleteFamily( wb_procom *pcom, pwr_tOix oix);
virtual void renameObject( wb_procom *pcom, pwr_tOix oix, char *name);
virtual void writeAttribute( wb_procom *pcom, pwr_tOix oix, unsigned int offset,
unsigned int size, char *buffer);
virtual void commit( wb_procom *pcom);
virtual void abort( wb_procom *pcom);
virtual char *longname( pwr_tOix oix);
virtual void delete_tree( pwr_tOix oix);
co_provider *m_provider;
virtual void save( pwr_tStatus *sts) {}
virtual void load( pwr_tStatus *sts) {}
virtual bool find( pwr_tOix fthoix, char *name, pwr_tOix *oix);
vector<pitem> m_list;
pwr_tOix root;
pwr_tOix next_oix;
co_procom( co_provider *p) : m_provider(p) {}
virtual ~co_procom() {}
virtual void provideObjects( pwr_tStatus, vector<procom_obj>&) {}
virtual void provideObject( pwr_tStatus sts, pwr_tOix oix, pwr_tOix fthoix, pwr_tOix bwsoix,
pwr_tOix fwsoix, pwr_tOix fchoix, pwr_tOix lchoix, pwr_tCid cid,
char *name, char *longname) {}
virtual void provideBody( pwr_tStatus sts, pwr_tOix oix, int size, void *body) {}
virtual void provideAttr( pwr_tStatus sts, pwr_tOix oix, int size, void *buff) {}
virtual void provideStatus( pwr_tStatus sts) {}
virtual void flushNodes() {};
};
#endif
/*
* Proview $Id: co_provider.h,v 1.1 2006-09-14 14:16:07 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.
*/
#ifndef co_provider_h
#define co_provider_h
class co_procom;
typedef enum {
pvd_eEnv_Wb,
pvd_eEnv_Rt
} pvd_eEnv;
class co_provider {
public:
pvd_eEnv m_env;
co_provider( pvd_eEnv env = pvd_eEnv_Wb) : m_env(env) {}
virtual ~co_provider() {}
virtual void object( co_procom *pcom) {}
virtual void objectOid( co_procom *pcom, pwr_tOix oix) {}
virtual void objectName( co_procom *pcom, char *name) {}
virtual void objectBody( co_procom *pcom, pwr_tOix oix) {}
virtual void createObject( co_procom *pcom, pwr_tOix destoix, int desttype,
pwr_tCid cid, char *name) {}
virtual void moveObject( co_procom *pcom, pwr_tOix oix, pwr_tOix destoix,
int desttype) {}
virtual void copyObject( co_procom *pcom, pwr_tOix oix, pwr_tOix destoix, int desttype,
char *name) {}
virtual void deleteObject( co_procom *pcom, pwr_tOix oix) {}
virtual void deleteFamily( co_procom *pcom, pwr_tOix oix) {}
virtual void renameObject( co_procom *pcom, pwr_tOix oix, char *name) {}
virtual void writeAttribute( co_procom *pcom, pwr_tOix oix, unsigned int offset,
unsigned int size, char *buffer) {}
virtual void readAttribute( co_procom *pcom, pwr_tOix oix, unsigned int offset,
unsigned int size) {}
virtual void commit( co_procom *pcom) {}
virtual void abort( co_procom *pcom) {}
virtual void subAssociateBuffer( co_procom *pcom, void **buff, int oix, int offset,
int size, pwr_tSubid sid) {}
virtual void subDisassociateBuffer( co_procom *pcom, pwr_tSubid sid) {}
virtual void cyclic( co_procom *pcom) {}
};
#endif
/*
* Proview $Id: wb_pvd_file.cpp,v 1.3 2005-11-22 12:23:30 claes Exp $
* Proview $Id: co_pvd_file.cpp,v 1.1 2006-09-14 14:16:07 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -26,9 +26,10 @@
#include "pwr_class.h"
#include "pwr_baseclasses.h"
#include "wb_vext.h"
#include "wb_pvd_file.h"
#include "co_pvd_file.h"
#include "wb_ldh.h"
#include "wb_ldh_msg.h"
#include "rt_gdh_msg.h"
extern "C" {
#include "co_cdh.h"
......@@ -37,7 +38,8 @@ extern "C" {
#define START_OIX 1000
void wb_pvd_file::object( wb_procom *pcom)
// Wb only
void co_pvd_file::object( co_procom *pcom)
{
if ( m_list.size() <= 1 || m_list[0].fchoix == 0) {
pcom->provideObject( LDH__NOSUCHOBJ,0,0,0,0,0,0,0,"","");
......@@ -46,33 +48,46 @@ void wb_pvd_file::object( wb_procom *pcom)
objectOid( pcom, m_list[0].fchoix);
}
void wb_pvd_file::objectOid( wb_procom *pcom, pwr_tOix oix)
void co_pvd_file::objectOid( co_procom *pcom, pwr_tOix oix)
{
if ( oix >= m_list.size() || oix <= 0) {
pcom->provideObject( LDH__NOSUCHOBJ,0,0,0,0,0,0,0,"","");
return;
if ( m_env == pvd_eEnv_Wb) {
if ( oix >= m_list.size() || oix <= 0) {
pcom->provideObject( LDH__NOSUCHOBJ,0,0,0,0,0,0,0,"","");
return;
}
pcom->provideObject( 1, oix, m_list[oix].fthoix, m_list[oix].bwsoix,
m_list[oix].fwsoix, m_list[oix].fchoix, m_list[oix].lchoix,
m_list[oix].cid, m_list[oix].name, longname(oix));
}
else {
if ( oix >= m_list.size() || oix < 0) {
pcom->provideStatus( GDH__NOSUCHOBJ);
return;
}
pcom->provideObjects( GDH__SUCCESS, m_list);
}
pcom->provideObject( 1, oix, m_list[oix].fthoix, m_list[oix].bwsoix,
m_list[oix].fwsoix, m_list[oix].fchoix, m_list[oix].lchoix,
m_list[oix].cid, m_list[oix].name, longname(oix));
}
void wb_pvd_file::objectName( wb_procom *pcom, char *name)
void co_pvd_file::objectName( co_procom *pcom, char *name)
{
for ( int i = 0; i < (int) m_list.size(); i++) {
if ( !m_list[i].flags & pitem_mFlags_Deleted) {
if ( !m_list[i].flags & procom_obj_mFlags_Deleted) {
if ( cdh_NoCaseStrcmp( name, longname(m_list[i].oix)) == 0) {
objectOid( pcom, i);
return;
}
}
}
pcom->provideObject( 0,0,0,0,0,0,0,0,"","");
if ( m_env == pvd_eEnv_Wb)
pcom->provideObject( 0,0,0,0,0,0,0,0,"","");
else
pcom->provideStatus( GDH__NOSUCHOBJ);
}
void wb_pvd_file::objectBody( wb_procom *pcom, pwr_tOix oix)
// Wb only
void co_pvd_file::objectBody( co_procom *pcom, pwr_tOix oix)
{
if ( oix >= m_list.size() || oix <= 0) {
pcom->provideBody( 0,0,0,0);
......@@ -85,10 +100,11 @@ void wb_pvd_file::objectBody( wb_procom *pcom, pwr_tOix oix)
pcom->provideBody( 0, 0, 0, 0);
}
void wb_pvd_file::createObject( wb_procom *pcom, pwr_tOix destoix, int desttype,
// Wb only
void co_pvd_file::createObject( co_procom *pcom, pwr_tOix destoix, int desttype,
pwr_tCid cid, char *name)
{
pitem item;
procom_obj item;
if ( destoix >= m_list.size()) {
pcom->provideObject( LDH__NOSUCHOBJ,0,0,0,0,0,0,0,"","");
......@@ -200,14 +216,15 @@ void wb_pvd_file::createObject( wb_procom *pcom, pwr_tOix destoix, int desttype,
sprintf( item.name, "O%d", item.oix);
else
strcpy( item.name, name);
item.flags |= pitem_mFlags_Created;
item.flags |= procom_obj_mFlags_Created;
m_list.push_back(item);
pcom->provideObject( 1, item.oix, item.fthoix, item.bwsoix, item.fwsoix,
item.fchoix, item.lchoix, item.cid, item.name, longname(item.oix));
}
void wb_pvd_file::moveObject( wb_procom *pcom, pwr_tOix oix, pwr_tOix destoix,
// Wb only
void co_pvd_file::moveObject( co_procom *pcom, pwr_tOix oix, pwr_tOix destoix,
int desttype)
{
if ( destoix >= m_list.size() || destoix <= 0) {
......@@ -277,13 +294,14 @@ void wb_pvd_file::moveObject( wb_procom *pcom, pwr_tOix oix, pwr_tOix destoix,
pcom->provideStatus( 1);
}
void wb_pvd_file::deleteObject( wb_procom *pcom, pwr_tOix oix)
// Wb only
void co_pvd_file::deleteObject( co_procom *pcom, pwr_tOix oix)
{
if ( oix >= m_list.size() || oix <= 0) {
pcom->provideStatus( 0);
return;
}
m_list[oix].flags |= pitem_mFlags_Deleted;
m_list[oix].flags |= procom_obj_mFlags_Deleted;
// Remove from current position
if ( m_list[oix].fthoix && m_list[m_list[oix].fthoix].fchoix == oix)
......@@ -298,7 +316,8 @@ void wb_pvd_file::deleteObject( wb_procom *pcom, pwr_tOix oix)
pcom->provideStatus( 1);
}
void wb_pvd_file::copyObject( wb_procom *pcom, pwr_tOix oix, pwr_tOix destoix, int desttype,
// Wb only
void co_pvd_file::copyObject( co_procom *pcom, pwr_tOix oix, pwr_tOix destoix, int desttype,
char *name)
{
......@@ -306,7 +325,7 @@ void wb_pvd_file::copyObject( wb_procom *pcom, pwr_tOix oix, pwr_tOix destoix, i
pcom->provideObject( LDH__NOSUCHOBJ,0,0,0,0,0,0,0,"","");
return;
}
pitem item = m_list[oix];
procom_obj item = m_list[oix];
item.oix = next_oix++;
if ( strcmp( name, "") == 0)
......@@ -364,7 +383,8 @@ void wb_pvd_file::copyObject( wb_procom *pcom, pwr_tOix oix, pwr_tOix destoix, i
item.fchoix, item.lchoix, item.cid, item.name, longname(item.oix));
}
void wb_pvd_file::deleteFamily( wb_procom *pcom, pwr_tOix oix)
// Wb only
void co_pvd_file::deleteFamily( co_procom *pcom, pwr_tOix oix)
{
if ( oix >= m_list.size() || oix <= 0) {
pcom->provideStatus( 0);
......@@ -385,7 +405,8 @@ void wb_pvd_file::deleteFamily( wb_procom *pcom, pwr_tOix oix)
pcom->provideStatus( 1);
}
void wb_pvd_file::renameObject( wb_procom *pcom, pwr_tOix oix, char *name)
// Wb only
void co_pvd_file::renameObject( co_procom *pcom, pwr_tOix oix, char *name)
{
if ( oix >= m_list.size() || oix <= 0) {
pcom->provideStatus( 0);
......@@ -396,7 +417,7 @@ void wb_pvd_file::renameObject( wb_procom *pcom, pwr_tOix oix, char *name)
pcom->provideStatus( 1);
}
void wb_pvd_file::writeAttribute( wb_procom *pcom, pwr_tOix oix, unsigned int offset,
void co_pvd_file::writeAttribute( co_procom *pcom, pwr_tOix oix, unsigned int offset,
unsigned int size, char *buffer)
{
if ( oix >= m_list.size() || oix <= 0) {
......@@ -413,7 +434,36 @@ void wb_pvd_file::writeAttribute( wb_procom *pcom, pwr_tOix oix, unsigned int of
pcom->provideStatus( 1);
}
void wb_pvd_file::commit( wb_procom *pcom)
// Rt only
void co_pvd_file::readAttribute( co_procom *pcom, pwr_tOix oix, unsigned int offset,
unsigned int size)
{
if ( oix >= m_list.size() || oix <= 0) {
pcom->provideStatus( GDH__NOSUCHOBJ);
return;
}
if ( offset + size > m_list[oix].body_size) {
pcom->provideStatus( GDH__NOSUCHOBJ);
return;
}
void *p = (void *)((unsigned long)m_list[oix].body + (unsigned long)offset);
pcom->provideAttr( GDH__SUCCESS, oix, size, p);
}
// Rt only
void co_pvd_file::subAssociateBuffer( co_procom *pcom, void **buff, int oix, int offset,
int size, pwr_tSubid sid)
{
if ( oix < (int)m_list.size())
*buff = (char *)m_list[oix].body + offset;
else
*buff = 0;
}
// Wb only
void co_pvd_file::commit( co_procom *pcom)
{
pwr_tStatus sts;
......@@ -421,7 +471,8 @@ void wb_pvd_file::commit( wb_procom *pcom)
pcom->provideStatus( sts);
}
void wb_pvd_file::abort( wb_procom *pcom)
// Wb only
void co_pvd_file::abort( co_procom *pcom)
{
pwr_tStatus sts;
......@@ -431,9 +482,9 @@ void wb_pvd_file::abort( wb_procom *pcom)
pcom->provideStatus( sts);
}
void wb_pvd_file::delete_tree( pwr_tOix oix)
void co_pvd_file::delete_tree( pwr_tOix oix)
{
m_list[oix].flags = pitem_mFlags_Deleted;
m_list[oix].flags = procom_obj_mFlags_Deleted;
for ( pwr_tOix ix = m_list[oix].fchoix;
ix;
......@@ -441,7 +492,7 @@ void wb_pvd_file::delete_tree( pwr_tOix oix)
delete_tree( ix);
}
char *wb_pvd_file::longname( pwr_tOix oix)
char *co_pvd_file::longname( pwr_tOix oix)
{
if ( m_list[oix].fthoix == 0)
strcpy( m_list[oix].lname, m_list[oix].name);
......@@ -453,11 +504,11 @@ char *wb_pvd_file::longname( pwr_tOix oix)
return m_list[oix].lname;
}
bool wb_pvd_file::find( pwr_tOix fthoix, char *name, pwr_tOix *oix)
bool co_pvd_file::find( pwr_tOix fthoix, char *name, pwr_tOix *oix)
{
for ( int i = 0; i < (int) m_list.size(); i++) {
if ( !m_list[i].flags & pitem_mFlags_Deleted) {
if ( !m_list[i].flags & procom_obj_mFlags_Deleted) {
if ( m_list[i].fthoix == fthoix &&
cdh_NoCaseStrcmp( name, m_list[i].name) == 0) {
*oix = m_list[i].oix;
......
/*
* Proview $Id: co_pvd_file.h,v 1.1 2006-09-14 14:16:07 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.
**/
#ifndef co_pvd_file_h
#define co_pvd_file_h
#include "co_provider.h"
#include "co_procom.h"
class co_pvd_file : public co_provider {
public:
co_pvd_file( pvd_eEnv env = pvd_eEnv_Wb) : co_provider(env), root(0), next_oix(1) {}
virtual void object( co_procom *pcom);
virtual void objectOid( co_procom *pcom, pwr_tOix oix);
virtual void objectName( co_procom *pcom, char *name);
virtual void objectBody( co_procom *pcom, pwr_tOix oix);
virtual void createObject( co_procom *pcom, pwr_tOix destoix, int desttype,
pwr_tCid cid, char *name);
virtual void moveObject( co_procom *pcom, pwr_tOix oix, pwr_tOix destoix, int desttype);
virtual void copyObject( co_procom *pcom, pwr_tOix oix, pwr_tOix destoix, int desttype,
char *name);
virtual void deleteObject( co_procom *pcom, pwr_tOix oix);
virtual void deleteFamily( co_procom *pcom, pwr_tOix oix);
virtual void renameObject( co_procom *pcom, pwr_tOix oix, char *name);
virtual void writeAttribute( co_procom *pcom, pwr_tOix oix, unsigned int offset,
unsigned int size, char *buffer);
virtual void readAttribute( co_procom *pcom, pwr_tOix oix, unsigned int offset,
unsigned int size);
virtual void subAssociateBuffer( co_procom *pcom, void **buff, int oix, int offset,
int size, pwr_tSubid sid);
virtual void commit( co_procom *pcom);
virtual void abort( co_procom *pcom);
virtual char *longname( pwr_tOix oix);
virtual void delete_tree( pwr_tOix oix);
virtual void save( pwr_tStatus *sts) {}
virtual void load( pwr_tStatus *rsts) {}
virtual bool find( pwr_tOix fthoix, char *name, pwr_tOix *oix);
vector<procom_obj> m_list;
pwr_tOix root;
pwr_tOix next_oix;
};
#endif
/*
* Proview $Id: wb_pvd_udb.cpp,v 1.2 2005-11-22 12:25:40 claes Exp $
* Proview $Id: co_pvd_udb.cpp,v 1.1 2006-09-14 14:16:07 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -26,7 +26,7 @@
#include "pwr_class.h"
#include "pwr_baseclasses.h"
#include "wb_vext.h"
#include "wb_pvd_udb.h"
#include "co_pvd_udb.h"
#include "wb_ldh.h"
#include "wb_ldh_msg.h"
......@@ -35,12 +35,12 @@ extern "C" {
#include "co_dcli.h"
}
void wb_pvd_udb::save( pwr_tStatus *sts)
void co_pvd_udb::save( pwr_tStatus *sts)
{
gu->clear();
for ( int i = 1; i < (int)m_list.size(); i++) {
if ( m_list[i].flags & pitem_mFlags_Deleted)
if ( m_list[i].flags & procom_obj_mFlags_Deleted)
continue;
switch ( m_list[i].cid) {
......@@ -71,7 +71,7 @@ void wb_pvd_udb::save( pwr_tStatus *sts)
*sts = gu->save();
}
char *wb_pvd_udb::groupname( char *name)
char *co_pvd_udb::groupname( char *name)
{
static char str[200];
char *s, *t;
......@@ -86,7 +86,7 @@ char *wb_pvd_udb::groupname( char *name)
return str;
}
void wb_pvd_udb::load( pwr_tStatus *rsts)
void co_pvd_udb::load( pwr_tStatus *rsts)
{
char filename[256];
int sts;
......@@ -99,10 +99,20 @@ void wb_pvd_udb::load( pwr_tStatus *rsts)
gu->load( filename);
// Create Root object
pitem rootitem;
strcpy( rootitem.name, "UserDatabase");
rootitem.cid = pwr_eClass_PlantHier;
rootitem.oix = 0;
procom_obj rootitem;
if ( m_env == pvd_eEnv_Wb) {
strcpy( rootitem.name, "UserDatabase");
rootitem.cid = pwr_eClass_PlantHier;
rootitem.oix = 0;
}
else {
strcpy( rootitem.name, "VolUserDatabase");
rootitem.cid = pwr_eClass_ExternVolume;
rootitem.oix = 0;
rootitem.body_size = sizeof(pwr_sExternVolume);
rootitem.body = calloc( 1, rootitem.body_size);
}
m_list.push_back(rootitem);
menu_stack[menu_cnt] = rootitem.oix;
menu_cnt++;
......@@ -113,11 +123,22 @@ void wb_pvd_udb::load( pwr_tStatus *rsts)
systemgroup = systemgroup->next_system();
}
if ( m_env == pvd_eEnv_Rt) {
// Convert to Rt style
for ( int i = 1; i < (int)m_list.size(); i++) {
if ( m_list[i].bwsoix == 0)
m_list[i].bwsoix = m_list[m_list[i].fthoix].lchoix;
if ( m_list[i].fwsoix == 0)
m_list[i].fwsoix = m_list[m_list[i].fthoix].fchoix;
}
}
}
void wb_pvd_udb::load_systemgroup( SystemList *systemgroup)
void co_pvd_udb::load_systemgroup( SystemList *systemgroup)
{
pitem item;
procom_obj item;
pwr_sClass_SystemGroupReg *body;
char sname[120];
char *s;
......@@ -161,9 +182,9 @@ void wb_pvd_udb::load_systemgroup( SystemList *systemgroup)
menu_cnt--;
}
void wb_pvd_udb::load_user( UserList *user, SystemList *sg)
void co_pvd_udb::load_user( UserList *user, SystemList *sg)
{
pitem item;
procom_obj item;
pwr_sClass_UserReg *body;
item.oix = next_oix++;
......
/*
* Proview $Id: wb_pvd_udb.h,v 1.1 2005-09-20 13:14:28 claes Exp $
* Proview $Id: co_pvd_udb.h,v 1.1 2006-09-14 14:16:07 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -19,20 +19,20 @@
// Provider for user database
#ifndef wb_pvd_udb_h
#define wb_pvd_udb_h
#ifndef co_pvd_udb_h
#define co_pvd_udb_h
#include "wb_pvd_file.h"
#include "co_pvd_file.h"
#include "co_user.h"
class wb_pvd_udb : public wb_pvd_file {
class co_pvd_udb : public co_pvd_file {
public:
wb_pvd_udb() : gu(0), menu_cnt(0)
co_pvd_udb( pvd_eEnv env = pvd_eEnv_Wb) : co_pvd_file(env), gu(0), menu_cnt(0)
{
pwr_tStatus sts;
load( &sts);
}
void load( pwr_tStatus *sts);
void load( pwr_tStatus *rsts);
void load_systemgroup( SystemList *systemgroup);
void load_user( UserList *user, SystemList *sg);
void save( pwr_tStatus *sts);
......
/*
* Proview $Id: rt_cmvolc.c,v 1.11 2006-07-27 10:27:01 claes Exp $
* Proview $Id: rt_cmvolc.c,v 1.12 2006-09-14 14:16:07 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -230,7 +230,7 @@ cmvolc_GetCachedClass (
smp->time = time;
smp->aidx = nextIdx;
rmp = net_Request(sts, &tgt, &put, NULL, net_eMsg_getCclassR, 0);
rmp = net_Request(sts, &tgt, &put, NULL, net_eMsg_getCclassR, 0, 0);
if (rmp == NULL || EVEN(rmp->sts))
goto netError;
......@@ -394,7 +394,7 @@ cmvolc_GetNonExistingClass (
smp->cid = cid;
smp->aidx = nextIdx;
rmp = net_Request(sts, &tgt, &put, NULL, net_eMsg_getGclassR, qdb_mGet_multipleGet);
rmp = net_Request(sts, &tgt, &put, NULL, net_eMsg_getGclassR, qdb_mGet_multipleGet, 0);
if (rmp == NULL || EVEN(rmp->sts))
goto netError;
......
/*
* Proview $Id: rt_cmvolsm.c,v 1.3 2005-09-01 14:57:55 claes Exp $
* Proview $Id: rt_cmvolsm.c,v 1.4 2006-09-14 14:16:07 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -141,7 +141,7 @@ cmvolsm_GetCclass (
else
rmp->sts = 1;
net_Reply(&lsts, get, &put);
net_Reply(&lsts, get, &put, 0);
}
......@@ -269,6 +269,6 @@ cmvolsm_GetGclass (
else
rmp->sts = 1;
net_Reply(&lsts, get, &put);
net_Reply(&lsts, get, &put, 0);
}
/*
* Proview $Id: rt_cvolc.c,v 1.7 2006-02-14 05:27:43 claes Exp $
* Proview $Id: rt_cvolc.c,v 1.8 2006-09-14 14:16:07 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -70,12 +70,11 @@ fetch (
np = hash_Search(sts, gdbroot->nid_ht, &vp->g.nid);
if (np == NULL) return NULL;
tgt.nid = np->nid;
tgt.qix = net_cProcHandler;
tgt = np->handler;
gdb_Unlock;
rsp = net_Request(&lsts, &tgt, put, &get, net_eMsg_objectR, 0);
rsp = net_Request(&lsts, &tgt, put, &get, net_eMsg_objectR, 0, 0);
gdb_Lock;
......@@ -142,11 +141,10 @@ cvolc_GetObjectInfo (
smp = net_Alloc(sts, &put, sizeof(*smp), net_eMsg_getObjectInfo);
if (smp == NULL) return sts;
tgt.nid = np->nid;
tgt.qix = net_cProcHandler;
tgt = np->handler;
smp->aref = *rarp;
rmp = net_Request(sts, &tgt, &put, NULL, net_eMsg_getObjectInfoR, 0);
rmp = net_Request(sts, &tgt, &put, NULL, net_eMsg_getObjectInfoR, 0, 0);
if (rmp == NULL) {
return NULL;
......@@ -236,11 +234,10 @@ cvolc_GetObjectInfo (
smp = net_Alloc(sts, &put, sizeof(*smp), net_eMsg_getObjectInfo);
if (smp == NULL) return sts;
tgt.nid = np->nid;
tgt.qix = net_cProcHandler;
tgt = np->handler;
smp->aref = *arp;
rmp = net_Request(sts, &tgt, &put, NULL, net_eMsg_getObjectInfoR, 0);
rmp = net_Request(sts, &tgt, &put, NULL, net_eMsg_getObjectInfoR, 0, 0);
if (rmp == NULL) {
return NULL;
......@@ -404,8 +401,7 @@ cvolc_SetObjectInfo (
cmvolc_AssumeLocked(ccp);
}
tgt.nid = np->nid;
tgt.qix = net_cProcHandler;
tgt = np->handler;
size = MIN(arp->Size, size);
......@@ -441,7 +437,7 @@ cvolc_SetObjectInfo (
}
}
rmp = net_Request(sts, &tgt, &put, NULL, net_eMsg_setObjectInfoR, 0);
rmp = net_Request(sts, &tgt, &put, NULL, net_eMsg_setObjectInfoR, 0, 0);
if (rmp == NULL) {
return NO;
......
/*
* Proview $Id: rt_cvolcm.c,v 1.2 2005-09-01 14:57:55 claes Exp $
* Proview $Id: rt_cvolcm.c,v 1.3 2006-09-14 14:16:07 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -253,7 +253,7 @@ cvolcm_FlushNode (
pwr_tStatus lsts;
gdb_AssumeLocked;
pwr_Assert(np != gdbroot->my_node && np != gdbroot->no_node);
pwr_Assert( np != gdbroot->my_node && np != gdbroot->no_node);
for (
vl = pool_Qsucc(NULL, gdbroot->pool, &np->own_lh);
......@@ -456,3 +456,47 @@ cvolcm_TrimOld (
cvol_FreeObject(NULL, vp, op, vol_mLink_cacheTrim);
}
}
void
cvolcm_ExternVolumeFlush(
gdb_sNode *np
)
{
pool_sQlink *vl;
gdb_sVolume *vp;
pool_sQlink *ol;
gdb_sObject *op;
gdb_sMountServer *msp;
pwr_tStatus sts;
// Flush local node
gdb_AssumeLocked;
for (
vl = pool_Qsucc(NULL, gdbroot->pool, &np->own_lh);
vl != &np->own_lh;
vl = pool_Qsucc(NULL, gdbroot->pool, vl)
) {
vp = pool_Qitem(vl, gdb_sVolume, l.own_ll);
pwr_Assert(vp->l.flags.b.isCached);
if (vp->l.flags.b.isCached) {
for (
ol = pool_Qsucc(NULL, gdbroot->pool, &vp->l.obj_lh);
ol != &vp->l.obj_lh;
ol = pool_Qsucc(NULL, gdbroot->pool, &vp->l.obj_lh)
) {
op = pool_Qitem(ol, gdb_sObject, l.obj_ll);
if (op->l.flags.b.isMountServer) {
msp = (gdb_sMountServer *) hash_Search(&sts, gdbroot->ms_ht, &op->g.oid);
if (msp == NULL) errh_Bugcheck(sts, "mount server inconsitency");
msp->msor = pool_cNRef;
pool_Qremove(NULL, gdbroot->pool, &msp->nodms_ll);
/* Todo !!! Clear alarm and blocklevel in all mount clients. */
}
cvol_FlushObject(op);
}
}
}
}
/*
* Proview $Id: rt_cvolcm.h,v 1.2 2005-09-01 14:57:55 claes Exp $
* Proview $Id: rt_cvolcm.h,v 1.3 2006-09-14 14:16:07 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -82,4 +82,8 @@ void
cvolcm_TrimOld (
);
void
cvolcm_ExternVolumeFlush(
gdb_sNode *np
);
#endif
/*
* Proview $Id: rt_cvols.c,v 1.3 2006-03-20 06:54:35 claes Exp $
* Proview $Id: rt_cvols.c,v 1.4 2006-09-14 14:16:07 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -109,7 +109,7 @@ cvols_Notify (
tgt.nid = np->nid;
if (!net_Put(&lsts, &tgt, &nmp->msg, nmp->subtype, 0, nmp->size))
if (!net_Put(&lsts, &tgt, &nmp->msg, nmp->subtype, 0, nmp->size, 0))
errh_Warning("Notify: error %x sending subtype %s to node %s", lsts, "Notify", np->name);
}
......
/*
* Proview $Id: rt_cvolsm.c,v 1.4 2005-12-13 15:14:27 claes Exp $
* Proview $Id: rt_cvolsm.c,v 1.5 2006-09-14 14:16:07 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -73,7 +73,7 @@ respondError (
rsp->oid = oid;
rsp->count = 0;
if (!net_Reply(&sts, get, &put))
if (!net_Reply(&sts, get, &put, 0))
errh_Bugcheck(sts, "net_Reply");
}
......@@ -166,7 +166,7 @@ respondObject (
rsp->oid = op->g.oid;
rsp->count = count + 1;
if (!net_Reply(&sts, get, &put))
if (!net_Reply(&sts, get, &put, 0))
errh_Bugcheck(sts, "net_Reply");
}
......@@ -276,7 +276,7 @@ cvolsm_GetObjectInfo (
rmp->sts = sts;
rmp->size = mp->aref.Size;
net_Reply(&sts, get, &put);
net_Reply(&sts, get, &put, 0);
}
/* Handle a NameToObject message. */
......@@ -404,5 +404,5 @@ cvolsm_SetObjectInfo (
rmp->aref = mp->aref;
rmp->sts = sts;
net_Reply(&sts, get, &put);
net_Reply(&sts, get, &put, 0);
}
/*
* Proview $Id: rt_dl.c,v 1.2 2005-09-01 14:57:55 claes Exp $
* Proview $Id: rt_dl.c,v 1.3 2006-09-14 14:16:07 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -70,7 +70,7 @@ dl_Cancel (
pool_Qremove(NULL, gdbroot->pool, &dp->dl_ll);
gdbroot->db->dl_lc--;
op = pool_Address(NULL, gdbroot->pool, dp->or);
op = pool_Address(NULL, gdbroot->pool, dp->opr);
if (op == NULL) errh_Bugcheck(GDH__WEIRD, "direct link inconsitency");
gdb_UnlockObject(sts, op);
......@@ -138,7 +138,7 @@ dl_Create (
dp->user = gdbroot->my_pid;
dp->aref = *arp;
dp->or = pool_ItemReference(NULL, gdbroot->pool, ap->op);
dp->opr = pool_ItemReference(NULL, gdbroot->pool, ap->op);
/* Lock the object */
......
/*
* Proview $Id: rt_dl.h,v 1.2 2005-09-01 14:57:55 claes Exp $
* Proview $Id: rt_dl.h,v 1.3 2006-09-14 14:16:07 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -39,7 +39,7 @@ typedef struct {
pwr_tSubid in subscription clients and servers */
pool_sQlink subc_htl; /* Subscription client hash table link. */
pool_sQlink dl_ll; /* Link to next/previous. */
pool_tRef or; /* Pool reference to object. */
pool_tRef opr; /* Pool reference to object. */
pid_t user; /* Who requested the direct link. */
pwr_sAttrRef aref; /* Object data referred. */
} dl_sLink;
......
/*
* Proview $Id: rt_gdb.h,v 1.12 2006-03-20 06:57:20 claes Exp $
* Proview $Id: rt_gdb.h,v 1.13 2006-09-14 14:16:07 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -153,6 +153,9 @@
#define gdb_cMin_pool_isize 600000
#define gdb_cMin_rtdb_isize 600000
#define gdb_Snid( nid, sid) (nid | (sid << 24))
#define gdb_SnidToQnid( snid) (snid & 0xffffff)
#define gdb_SnidToSid( snid) (snid >> 24)
/* General database lock to keep consistency.
......@@ -961,6 +964,7 @@ typedef struct {
pwr_tUInt32 txmsg[net_eMsg_];
qcom_sQid handler; /**< Nethandler que */
} gdb_sNode;
......
/*
* Proview $Id: rt_gdh.c,v 1.27 2006-09-06 12:36:35 claes Exp $
* Proview $Id: rt_gdh.c,v 1.28 2006-09-14 14:16:07 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -283,6 +283,43 @@ gdh_ClassAttrToAttrref (
return sts;
}
/**
* @brief Get the attribute name from a class and attrref.
*
* The objid of the attrref is not used.
* @return Status of the operation.
*/
pwr_tStatus
gdh_ClassAttrrefToAttr (
pwr_tClassId cid, /**< The class identity whose attribute we want to examin */
pwr_sAttrRef *arp, /**< Attribute description. */
char *name, /**< The returned name of the attribute */
int size /**< Max size of the returned name */
)
{
pwr_tStatus sts = GDH__SUCCESS;
mvol_sAttribute Attribute;
mvol_sAttribute *ap;
if (arp == NULL) return GDH__BADARG;
if (name == NULL) return GDH__BADARG;
memset(&Attribute, 0, sizeof(Attribute));
gdh_ScopeLock {
ap = mvol_ArefToAttribute( &sts, &Attribute, arp, cid);
} gdh_ScopeUnlock;
if (ap != NULL)
strncpy( name, ap->name, size);
return sts;
}
/**
* @brief Get the class identity corresponding to a class
......
/*
* Proview $Id: rt_gdh.h,v 1.14 2006-01-13 16:32:39 claes Exp $
* Proview $Id: rt_gdh.h,v 1.15 2006-09-14 14:16:07 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -600,6 +600,14 @@ gdh_ClassAttrToAttrref (
pwr_sAttrRef *attributeReference
);
pwr_tStatus
gdh_ClassAttrrefToAttr (
pwr_tClassId classid,
pwr_sAttrRef *attributeReference,
char *nameBuffer,
int sizeOfNameBuffer
);
pwr_tStatus
gdh_GetAttributeCharAttrref (
pwr_sAttrRef *attributeReference,
......
/*
* Proview $Id: rt_net.c,v 1.8 2006-03-20 07:01:56 claes Exp $
* Proview $Id: rt_net.c,v 1.9 2006-09-14 14:16:07 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -193,7 +193,8 @@ static tFuncXdr func_xdr[net_eMsg_] = {
(tFuncXdr)xdr_net_sGetCclass,
(tFuncXdr)xdr_net_sGetCclassR,
(tFuncXdr)xdr_net_sGetGclass,
(tFuncXdr)xdr_net_sGetGclassR
(tFuncXdr)xdr_net_sGetGclassR,
(tFuncXdr)xdr_net_sId /* Sever connect */
};
......@@ -238,10 +239,13 @@ ConvertPut (
XDR xdrs;
qdb_sNode *np;
tFuncXdr fXdr;
pwr_tNid nid;
if (put->type.b != net_cMsgClass)
pwr_Return(FALSE, sts, NET__XDRFAILED);
np = hash_Search(&lsts, &qdb->nid_ht, &qid->nid);
// Remove sid
nid = qid->nid & 0xffffff;
np = hash_Search(&lsts, &qdb->nid_ht, &nid);
if (np == NULL) pwr_Return(FALSE, sts, lsts);
/* This is a simple way to fix the net_sGvolume difference between
......@@ -605,14 +609,15 @@ pwr_tBoolean
net_Reply (
pwr_tStatus *status,
qcom_sGet *get,
qcom_sPut *put
qcom_sPut *put,
pwr_tSid sid
)
{
pwr_tBoolean ok;
pwr_dStatus (sts, status, NET__SUCCESS);
((net_sMessage *)put->data)->msn = ((net_sMessage *)get->data)->msn;
((net_sMessage *)put->data)->nid = gdbroot->db->nid;
((net_sMessage *)put->data)->nid = gdb_Snid(gdbroot->db->nid, sid);
NET_LOCK;
ok = Reply(sts, get, put);
......@@ -628,14 +633,15 @@ net_Put (
void *mp,
net_eMsg type,
unsigned int id,
int size
int size,
pwr_tSid sid
)
{
pwr_tBoolean ok;
pwr_dStatus (sts, status, NET__SUCCESS);
((net_sMessage *)mp)->msn = 0;
((net_sMessage *)mp)->nid = gdbroot->db->nid;
((net_sMessage *)mp)->nid = gdb_Snid( gdbroot->db->nid, sid);
NET_LOCK;
ok = Put(sts, tgt, mp, type, id, size);
......@@ -670,7 +676,8 @@ net_Request (
qcom_sPut *put,
qcom_sGet *get,
net_eMsg gtype,
pwr_tBitMask flags
pwr_tBitMask flags,
pwr_tSid sid
)
{
void *p;
......@@ -679,7 +686,7 @@ net_Request (
gdb_AssumeUnlocked;
((net_sMessage *)put->data)->msn = gdbroot->db->rqgen++;
((net_sMessage *)put->data)->nid = gdbroot->db->nid;
((net_sMessage *)put->data)->nid = gdb_Snid( gdbroot->db->nid, sid);
NET_LOCK;
p = Request(sts, tgt, put, get, gtype, flags);
......
#ifdef RPC_HDR
%/*
% * Proview $Id: rt_net.x,v 1.10 2006-03-20 07:01:56 claes Exp $
% * Proview $Id: rt_net.x,v 1.11 2006-09-14 14:16:07 claes Exp $
% * Copyright (C) 2005 SSAB Oxelsund AB.
% *
% * This program is free software; you can redistribute it and/or
......@@ -101,6 +101,8 @@ enum net_eMsg {
net_eMsg_getGclass, /* The whole class */
net_eMsg_getGclassR,
net_eMsg_serverConnect, /* New server */
net_eMsg_, /* Not a valid message */
net_eMsg_volumes7, /* Version 7. Internal only */
......@@ -1279,7 +1281,8 @@ struct net_sGetCclass {
%net_Reply (
% pwr_tStatus *sts,
% qcom_sGet *get,
% qcom_sPut *put
% qcom_sPut *put,
% pwr_tSid sid
%);
%
%pwr_tBoolean
......@@ -1289,7 +1292,8 @@ struct net_sGetCclass {
% void *mp,
% net_eMsg type,
% unsigned int id,
% int size
% int size,
% pwr_tSid sid
%);
%
%void *
......@@ -1306,7 +1310,8 @@ struct net_sGetCclass {
% qcom_sPut *put,
% qcom_sGet *get,
% net_eMsg gtype,
% pwr_tBitMask flags
% pwr_tBitMask flags,
% pwr_tSid sid
%);
%
%pwr_tBoolean
......
/*
* Proview $Id: rt_procom.cpp,v 1.1 2006-09-14 14:16:07 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.
*/
/* rt_provider.c -- Runtime provider test */
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <vector.h>
#include <map.h>
extern "C" {
#include "pwr.h"
#include "co_time.h"
#include "rt_qcom_msg.h"
#include "rt_qcom.h"
#include "rt_errh.h"
#include "rt_qdb.h"
#include "rt_gdh_msg.h"
#include "rt_gdb.h"
#include "rt_gdh.h"
#include "rt_dl.h"
#include "rt_ini_event.h"
#include "rt_net.h"
#include "rt_san.h"
#include "rt_sancm.h"
#include "rt_sansm.h"
#include "rt_sub.h"
#include "rt_subc.h"
#include "rt_subsm.h"
#include "rt_subcm.h"
#include "rt_cmvolsm.h"
#include "rt_cvol.h"
#include "rt_cvolsm.h"
#include "rt_cvolcm.h"
#include "rt_pwr_msg.h"
#include "rt_ndc.h"
}
#include "co_provider.h"
#include "rt_procom.h"
class psub {
public:
psub() : occupied(1), count(0), nid(0), dt(0), sub_by_name(0), p(0) {}
int occupied;
pwr_tSubid sid;
pwr_tUInt32 count;
pwr_tNodeId nid;
pwr_tUInt32 dt;
pwr_tBoolean sub_by_name;
pwr_sAttrRef aref;
void *p;
};
class subkey {
public:
int m_nid;
int m_rix;
subkey() : m_nid(0), m_rix(0) {}
subkey( pwr_tSubid sid) : m_nid(sid.nid), m_rix(sid.rix) {}
friend bool operator<(const subkey x1, const subkey x2) {
if ( x1.m_nid < x2.m_nid)
return true;
if ( x1.m_nid == x2.m_nid && x1.m_rix < x2.m_rix)
return true;
return false;
}
};
typedef map<subkey, psub>::iterator sublist_iterator;
map<subkey, psub> m_sublist;
static rt_procom *pvd_procom;
rt_procom::rt_procom( co_provider *p, errh_eAnix anix, char *name, pwr_tSid sid, pwr_tVid vid,
char *volumename, int global) :
co_procom(p), m_anix(anix), m_sid(sid), m_vid(vid), m_global(global), m_getmsg(0)
{
pvd_procom = this;
strcpy( m_name, name);
strcpy( m_volumename, volumename);
}
// Configuration data
static qcom_tQix pvd_qix = 0; // 1 << 30;
static qcom_sQid pvd_qid;
/* Declare routines used by main. */
static void addMyNode (void);
static gdb_sNode* addNode (qcom_sNode*);
static void bugError (qcom_sGet*);
static void flush (qcom_sGet*);
static void flushNode (gdb_sNode*);
static void flushAllNodes (void);
static void fromNet (qcom_sGet*);
static void id (qcom_sGet*);
static void idAck2 (qcom_sGet*);
static void linkActive (qcom_sGet*);
static void linkConnect (qcom_sGet*);
static void linkDisconnect (qcom_sGet*);
static void linkStalled (qcom_sGet*);
static void netError (qcom_sGet*);
static void sendFlush (gdb_sNode*);
static void sendId (gdb_sNode*);
static void sendVolumes (gdb_sNode*, pool_tRef);
static void volumes (qcom_sGet*);
static void volumesR (qcom_sGet*);
static void volumes7 (qcom_sGet*);
#if 0
static void linkEvent (pwr_tUInt32, net_eEvent);
static void sendIdAck (gdb_sNode*);
static void sendIdAck2 (gdb_sNode*);
#endif
static void
respondError (
qcom_sGet *get,
pwr_tObjid oid,
pwr_tStatus rspsts
);
void
pvd_OidToObject (
qcom_sGet *get
);
void
pvd_NameToObject (
qcom_sGet *get
);
static void
sendServerConnect (
gdb_sNode *np
);
static void
sendServerConnectAll (
);
static void
pvd_GetObjectInfo (
qcom_sGet *get
);
static void
pvd_SetObjectInfo (
qcom_sGet *get
);
static void
pvd_SubAdd (
qcom_sGet *get
);
static void
pvd_SubRemove (
qcom_sGet *get
);
static pwr_tBoolean
pvd_SubSendBuffer ();
/* Dispatcher for 'net_cMsgClass' messages. */
static char *cMsg[net_eMsg_end] = {
"error",
"id",
"idAck",
"idAck2",
"volumes",
"volumesR",
"subAdd",
"subRemove",
"subData",
"sanAdd",
"sanRemove",
"sanUpdate",
"nameToObject",
"oidToObject",
"objectR",
"getObjectInfo",
"getObjectInfoR",
"setObjectInfo",
"setObjectInfoR",
"flush",
"createObject",
"deleteObject",
"moveObject",
"renameObject",
"nodeUp",
"nodeDown",
"getCclass",
"getCclassR",
"getGclass",
"getGclassR",
"net_eMsg_",
"volumes7"
"net_eMsg_",
};
static void (*fromApplication[net_eMsg_end])(qcom_sGet *) = {
netError,
id,
id,
idAck2,
volumes,
volumesR,
pvd_SubAdd, /* Add subscription */
pvd_SubRemove, /* Remove subscription */
subcm_Data, /* Subscription data transfer */
sansm_Add, /* Add subscription */
sansm_Remove, /* Remove subscription */
sancm_Update, /* Subscription data transfer */
pvd_NameToObject, /* Cache inquiry, fetch name */
pvd_OidToObject, /* Cache inquiry, fetch objid */
bugError, /* net_eMsg_ObjectR will never reach neth. */
pvd_GetObjectInfo,
bugError, /* net_eMsg_GetObjectInfoR will never reach neth. */
pvd_SetObjectInfo,
bugError, /* net_eMsg_SetObjectInfoR, will never reach neth. */
flush, /* net_eMsg_Flush, Cache flush request */
cvolcm_CreateObject,
cvolcm_DeleteObject,
cvolcm_MoveObject,
cvolcm_RenameObject,
bugError, /* net_eMsg_NodeUp will never reach neth. */
bugError, /* net_eMsg_NodeDown is not for neth. */
cmvolsm_GetCclass,
bugError, /* net_eMsg_GetCclassR will never reach neth */
cmvolsm_GetGclass,
bugError, /* net_eMsg_GetGclassR will never reach neth */
bugError, /* net_eMsg_ */
volumes7,
bugError /* net_eMsg_serverConnect */
};
#if 0
int
main (
int argc,
char **argv
)
{
init();
/* Start receive loop which never exits (hopefully). */
mainLoop();
exit(1);
}
#endif
/* Add my own node. */
static void
addMyNode (void)
{
pwr_tStatus sts;
qcom_sNode node;
gdb_sNode *np;
qcom_MyNode(&sts, &node);
if (EVEN(sts)) errh_Bugcheck(sts, "qcom_MyNode");
if (node.nid != gdbroot->db->nid)
errh_Bugcheck(GDH__WEIRD, "Qcom and Gdb dont agree on node identity");
np = addNode(&node);
if (np == NULL) errh_Bugcheck(0, "addNode(myNode)");
gdb_ScopeLock {
np->netver = net_cVersion;
np->cclassSupport = FALSE;
np->handler = pvd_qid;
} gdb_ScopeUnlock;
}
/* Add my own node. */
static gdb_sNode *
addNode (
qcom_sNode *node
)
{
pwr_tStatus sts;
gdb_sNode *np;
gdb_ScopeLock {
np = gdb_AddNode(&sts, gdb_Snid( node->nid, pvd_procom->m_sid), gdb_mAdd__);
if (np == NULL) break;
sprintf(np->name, "%s_s%d", node->name, pvd_procom->m_sid);
np->os = node->os;
np->hw = node->hw;
np->upcnt++;
clock_gettime( CLOCK_REALTIME, &np->timeup);
co_SetFormat(&np->fm, node->bo, node->ft);
gdbroot->my_node = np;
if (np == gdbroot->my_node)
np->flags.m |= net_eState_up; /* ERROR. ERROR, ERROR !!! */
} gdb_ScopeUnlock;
return np;
}
/* Send flush to all connected node. */
static void
flushAllNodes (void)
{
pwr_tStatus sts;
pwr_tNodeId nid;
qcom_sNode node;
gdb_sNode* np;
gdb_AssumeUnlocked;
for (nid = qcom_cNNid; qcom_NextNode(&sts, &node, nid); nid = node.nid) {
gdb_ScopeLock {
np = (gdb_sNode *) hash_Search(&sts, gdbroot->nid_ht, &node.nid);
} gdb_ScopeUnlock;
if (np == NULL)
continue;
if (np == gdbroot->my_node || np == gdbroot->no_node)
continue;
if (node.flags.b.connected) {
sendFlush(np);
#if 0
sendVolumes(np, pool_cNRef);
#endif
}
}
}
/* Handle messages that should not reach net handler. */
static void
bugError (
qcom_sGet *get
)
{
errh_Warning("Unexpected message type <%d:%d> received from %x @ %s",
get->type.b, get->type.s, get->pid,
cdh_NodeIdToString(NULL, get->sender.nid, 0, 0));
}
/* Flush all information on remote node. */
static void
flushNode (
gdb_sNode *np
)
{
gdb_ScopeLock {
cvolcm_FlushNode(NULL, np);
cvolsm_FlushNode(NULL, np);
subsm_FlushNode(NULL, np);
subcm_FlushNode(NULL, np);
sansm_FlushNode(NULL, np);
sancm_FlushNode(NULL, np);
} gdb_ScopeUnlock;
}
static void
fromEvent (
qcom_sGet *get
)
{
static int sav_event = 0;
ini_mEvent cur_event;
ini_mEvent new_event;
qcom_sEvent *ep = (qcom_sEvent*) get->data;
if (get->type.s != qcom_cIini)
return;
cur_event.m = sav_event;
new_event.m = ep->mask;
if (new_event.b.swapDone & !cur_event.b.swapDone) {
errh_Info("Warm restart completed.");
flushAllNodes();
} else if (new_event.b.swapInit & !cur_event.b.swapInit) {
errh_Info("Warm restart initiated.");
} else if (new_event.b.terminate & !cur_event.b.terminate) {
exit(0);
}
sav_event = ep->mask;
}
/* Dispatcher for MSG_CLAS_PAMS messages. */
static void
fromNet (
qcom_sGet *get
)
{
switch (get->type.s) {
case qcom_eStype_linkActive:
linkActive(get);
break;
case qcom_eStype_linkConnect:
linkConnect(get);
break;
case qcom_eStype_linkDisconnect:
linkDisconnect(get);
break;
case qcom_eStype_linkStalled:
linkStalled(get);
break;
case qcom_eStype_applConnect:
/* Nothing needs to be done */
break;
case qcom_eStype_applDisconnect:
break;
default:
errh_Error("Unexpected message type <%d:%d> received from %x @ %s",
get->type.b, get->type.s, get->pid,
cdh_NodeIdToString(NULL, get->sender.nid, 0, 0));
break;
}
}
/* Flush a node. */
static void
flush (
qcom_sGet *get
)
{
pwr_tStatus sts;
net_sId *mp = (net_sId *) get->data;
gdb_sNode *np;
gdb_AssumeUnlocked;
gdb_ScopeLock {
np = (gdb_sNode *) hash_Search(&sts, gdbroot->nid_ht, &mp->hdr.nid);
} gdb_ScopeUnlock;
if (np == NULL)
return;
if (np->flags.b.connected) {
errh_Info("Flushing, node %s (%s)", np->name, cdh_NodeIdToString(NULL, np->nid, 0, 0));
flushNode(np);
sendId(np);
}
}
/* Received Id or IdAck. */
static void
id (
qcom_sGet *get
)
{
net_sId *mp = (net_sId *) get->data;
pwr_tStatus sts;
gdb_sNode *np;
net_eEvent event;
pwr_tBoolean cclassSupport = FALSE;
gdb_AssumeUnlocked;
if (gdbroot->db->log.b.messages) {
errh_Info("Received '%s' from nid %s",
cMsg[get->type.s], cdh_NodeIdToString(NULL, mp->hdr.nid, 0, 0));
}
if (mp->hdr.nid == gdbroot->my_node->nid ) {
errh_Error("New node using nid %s, attempts to appear as local node %s, '%s' ignored",
cdh_NodeIdToString(NULL, get->sender.nid, 0, 0),
cdh_NodeIdToString(NULL, mp->hdr.nid, 0, 0),
cMsg[get->type.s]);
return;
}
if (mp->node.netver != net_cVersion) {
if (mp->node.netver == 7) {
cclassSupport = FALSE;
errh_Warning("Accepting older net protocol version, '%s' old version: %d, my version: %d, node: %s",
cMsg[get->type.s], mp->node.netver, net_cVersion,
cdh_NodeIdToString(NULL, get->sender.nid, 0, 0));
} else if (mp->node.netver > net_cVersion) {
errh_Warning("Accepting newer net protocol version, '%s' new version: %d, my version: %d, node: %s",
cMsg[get->type.s], mp->node.netver, net_cVersion,
cdh_NodeIdToString(NULL, get->sender.nid, 0, 0));
} else {
errh_Error("Proview net protocol version not supported, '%s' ignored version: %d, my version: %d, node: %s",
cMsg[get->type.s], mp->node.netver, net_cVersion,
cdh_NodeIdToString(NULL, get->sender.nid, 0, 0));
return;
}
}
if ((net_eMsg)get->type.s == net_eMsg_id)
event = net_eEvent_id;
else
event = net_eEvent_idAck;
gdb_ScopeLock {
// np = gdb_AddNode(NULL, get->sender.nid, gdb_mAdd__);
np = (gdb_sNode *) hash_Search(&sts, gdbroot->nid_ht, &mp->hdr.nid);
if (np == NULL) {
errh_Warning("New node (%s) not connected",
cdh_NodeIdToString(NULL, get->sender.nid, 0, 0));
event = net_eEvent_error;
break;
}
// np->nod_oid = mp->node.nod_oid;
// np->netver = mp->node.netver;
// np->cclassSupport = cclassSupport;
} gdb_ScopeUnlock;
sendVolumes(np, pool_cNRef);
}
/* Handle neti response. Add node to nodedb. */
static void
idAck2 (
qcom_sGet *get
)
{
errh_Error("Received 'idAck2' from (%s)",
cdh_NodeIdToString(NULL, get->sender.nid, 0, 0));
}
/* Initialize the nethandler data and communications. */
void rt_procom::init()
{
pwr_tStatus sts;
qcom_sQid qid;
errh_Init( m_name, m_anix);
errh_SetStatus( PWR__SRVSTARTUP);
/* NOTA BENE !
The net handler does not call gdh_Init and thus may not use
the externally callable interface of GDH. */
qid.qix = pvd_qix;
qid.nid = qcom_cNNid;
gdb_MapDb(&sts, &qid, m_name);
if (EVEN (sts)) {
errh_Error("gdb_MapDb, %m", sts);
errh_SetStatus( PWR__SRVTERM);
exit(sts);
}
// gdbroot->db->nethandler = qid;
pvd_qid = qid;
if (!qcom_Bind(&sts, &gdbroot->my_qid, &qcom_cQnetEvent)) {
errh_Error("qcom_Bind(QnetEvent), %m", sts);
errh_SetStatus( PWR__SRVTERM);
exit(sts);
}
if (!qcom_Bind(&sts, &gdbroot->my_qid, &qcom_cQapplEvent)) {
errh_Error("qcom_Bind(QapplEvent), %m", sts);
errh_SetStatus( PWR__SRVTERM);
exit(sts);
}
if (!qcom_Bind(&sts, &gdbroot->my_qid, &qcom_cQini)) {
errh_Error("qcom_Bind(Qini), %m", sts);
errh_SetStatus( PWR__SRVTERM);
exit(sts);
}
addMyNode();
sendServerConnectAll();
}
static void
linkActive (
qcom_sGet *get
)
{
pwr_tStatus sts;
qcom_sNode *node = (qcom_sNode *)get->data;
gdb_sNode *np;
gdb_AssumeUnlocked;
gdb_ScopeLock {
np = gdb_AddNode(&sts, node->nid, gdb_mAdd__);
} gdb_ScopeUnlock;
if (!np->flags.b.active) {
errh_Info("Active, link to node %s (%s)",
node->name, cdh_NodeIdToString(NULL, node->nid, 0, 0));
pwr_Assert(np->flags.b.connected);
np->flags.b.active = 1;
}
}
static void linkConnect ( qcom_sGet *get)
{
gdb_sNode *np;
qcom_sNode *node =(qcom_sNode *)get->data;
if (!pvd_procom->m_global)
return;
np = (gdb_sNode *) hash_Search(NULL, gdbroot->nid_ht, &node->nid);
sendServerConnect( np);
}
static void linkDisconnect ( qcom_sGet *get)
{
}
static void linkStalled ( qcom_sGet *get)
{
}
/* Receive messages. */
void rt_procom::mainLoop()
{
pwr_tStatus sts;
qcom_sGet get;
void *mp;
pwr_tBoolean log_alloc_fail = TRUE;
int tmo = 1000;
errh_SetStatus( PWR__SRUN);
for (;;) {
memset(&get, 0, sizeof(get));
mp = net_Receive(&sts, &get, tmo);
if ( sts == QCOM__TMO) {
m_provider->cyclic( this);
pvd_SubSendBuffer();
continue;
}
if (mp == NULL) {
if (log_alloc_fail) errh_Error("net_Receive %m", sts);
log_alloc_fail = FALSE;
continue;
}
log_alloc_fail = TRUE;
switch (get.type.b) {
case qcom_eBtype_qcom:
if (gdbroot->db->log.b.messages)
errh_Info("Received message from %x (%d) @ %s, aix: %d, type=%d, subtype=%d and length=%d",
get.pid, get.pid, cdh_NodeIdToString(NULL, get.sender.nid, 0, 0),
get.sender.aix, get.type.b, get.type.b, get.size);
fromNet(&get);
break;
case net_cMsgClass:
if (((int)get.type.s > (int)net_eMsg__ && (int)get.type.s < (int)net_eMsg_)
|| ((net_eMsg) get.type.s == net_eMsg_volumes7)
) {
if (gdbroot->db->log.b.messages) {
errh_Info("Received '%s' from %x @ %s, length=%d",
cMsg[get.type.s], get.pid,
cdh_NodeIdToString(NULL, get.sender.nid, 0, 0), get.size);
}
fromApplication[get.type.s](&get);
} else {
errh_Warning("Unexpected message sub type %d", get.type.s);
}
break;
case qcom_eBtype_event:
fromEvent(&get);
break;
default:
errh_Warning("Unexpected message type %d, subtype %d\n pid %x sender.aix %d, sender.nid 0x%x\n, reply.qix 0x%x, reply.nid 0x%x",
get.type.b, get.type.s, get.pid, get.sender.aix, get.sender.nid,
get.reply.qix, get.reply.nid);
break;
}
qcom_Free(&sts, mp);
pvd_SubSendBuffer();
}
}
static void netError ( qcom_sGet *get)
{
}
static void sendFlush ( gdb_sNode *np)
{
}
/* This routine sends an id to a remote node. */
static void
sendId (
gdb_sNode *np
)
{
pwr_tStatus sts;
net_sId msg;
qcom_sQid tgt;
pwr_tUInt32 size;
if (gdbroot->db->log.b.id) {
errh_Info("Sending 'id' to %s (%s)",
np->name, cdh_NodeIdToString(NULL, np->nid, 0, 0));
}
tgt.nid = np->nid;
tgt.qix = net_cProcHandler;
size = sizeof(msg);
msg.node.handler = pvd_qid;
msg.node.netver = net_cVersion;
msg.hdr.nid = gdbroot->my_node->nid;
msg.node.nod_oid = gdbroot->my_node->nod_oid;
msg.node.vol_oid = gdbroot->my_node->vol_oid;
net_Put(&sts, &tgt, &msg, net_eMsg_id, 0, size, pvd_procom->m_sid);
if (EVEN(sts))
errh_Error("Sending 'id' to %s (%s)\n%m",
np->name, cdh_NodeIdToString(NULL, np->nid, 0, 0), sts);
}
/* Send a list of all volumes owned by this node to the
remote node. */
static void
sendVolumes (
gdb_sNode *np,
pool_tRef vr
)
{
pwr_tStatus sts;
net_sVolumes *mp;
net_sVolumes7 *m7p;
qcom_sQid tgt;
pwr_tUInt32 size;
pwr_tBoolean cclassSupport;
net_eMsg msgtype;
int nVol = 1;
cdh_sObjName oname;
if (gdbroot->db->log.b.messages) {
errh_Info("Sending 'volumes' to %s (%s)",
np->name, cdh_NodeIdToString(NULL, np->nid, 0, 0));
}
cclassSupport = np->cclassSupport;
if (!cclassSupport)
size = sizeof(*m7p) + ((nVol - 1) * sizeof(m7p->g[0]));
else
size = sizeof(*mp) + ((nVol - 1) * sizeof(mp->g[0]));
mp = (net_sVolumes *) malloc(size);
if (mp == NULL) {
errh_Error("Failed to allocate 'volumes' to %s (%s)",
np->name, cdh_NodeIdToString(NULL, np->nid, 0, 0));
return;
}
cdh_ObjName( &oname, pvd_procom->m_volumename);
if (!cclassSupport) {
m7p = (net_sVolumes7 *) mp;
m7p->g[0].vid = pvd_procom->m_vid;
m7p->g[0].oid.oix = 0;
m7p->g[0].oid.vid = pvd_procom->m_vid;
m7p->g[0].name = oname;
m7p->g[0].cid = pwr_eClass_ExternVolume;
m7p->g[0].nid = gdbroot->my_node->nid;
msgtype = net_eMsg_volumes7;
}
else {
mp->g[0].vid = pvd_procom->m_vid;
mp->g[0].oid.oix = 0;
mp->g[0].oid.vid = pvd_procom->m_vid;
mp->g[0].name = oname;
mp->g[0].cid = pwr_eClass_ExternVolume;
mp->g[0].nid = gdbroot->my_node->nid;
mp->g[0].time = pwr_cNTime;
msgtype = net_eMsg_volumes;
}
mp->count = 1;
mp->ctx = pool_cNRef;
tgt.nid = np->nid;
tgt.qix = net_cProcHandler;
if (!net_Put(&sts, &tgt, mp, msgtype, 0, size, 0))
errh_Error("Sending 'volumes' to %s (%s)\n%m",
np->name, cdh_NodeIdToString(NULL, np->nid, 0, 0), sts);
free(mp);
}
/* Receive a list of all volumes owned by the sending node. */
static void
volumes (
qcom_sGet *get
)
{
}
/* Receive a list of all volumes owned by the sending node.
* Neth version 7 of net_sVolumes
*/
static void
volumes7 (
qcom_sGet *get
)
{
}
/* Receive a list of all volumes the remote node have mounted. */
static void
volumesR (
qcom_sGet *get
)
{
net_sVolumesR *mp = (net_sVolumesR *) get->data;
gdb_sNode *np;
gdb_ScopeLock {
np = (gdb_sNode *) hash_Search(NULL, gdbroot->nid_ht, &mp->hdr.nid);
if (!np->flags.b.connected) {
np = NULL;
break;
}
} gdb_ScopeUnlock;
if (np == NULL)
return;
if (mp->ctx != pool_cNRef)
sendVolumes(np, mp->ctx);
}
void
pvd_OidToObject (
qcom_sGet *get
)
{
net_sOidToObject *mp = (net_sOidToObject *)get->data;
if ( mp->oid.vid == pvd_procom->m_vid) {
pvd_procom->m_getmsg = get;
pvd_procom->m_provider->objectOid( pvd_procom, mp->oid.oix);
}
else
respondError(get, pwr_cNObjid, GDH__NOSUCHOBJ);
}
void
pvd_NameToObject (
qcom_sGet *get
)
{
net_sNameToObject *mp = (net_sNameToObject *)get->data;
pvd_procom->m_getmsg = get;
pvd_procom->m_provider->objectName( pvd_procom, mp->name);
}
static void
respondError (
qcom_sGet *get,
pwr_tObjid oid,
pwr_tStatus rspsts
)
{
pwr_tStatus sts;
net_sObjectR *rsp;
qcom_sPut put;
rsp = (net_sObjectR *) net_Alloc(&sts, &put, sizeof(*rsp), net_eMsg_objectR);
if (rsp == NULL) errh_Bugcheck(sts, "net_Alloc");
rsp->sts = rspsts;
rsp->oid = oid;
rsp->count = 0;
if (!net_Reply(&sts, get, &put, 0))
errh_Bugcheck(sts, "net_Reply");
}
/* This routine sends serverConnect to a node. */
static void
sendServerConnect (
gdb_sNode *np
)
{
pwr_tStatus sts;
net_sId msg;
qcom_sQid tgt;
pwr_tUInt32 size;
if (gdbroot->db->log.b.id) {
errh_Info("Sending 'serverConnect' to %s (%s)",
np->name, cdh_NodeIdToString(NULL, np->nid, 0, 0));
}
tgt.nid = np->nid;
tgt.qix = net_cProcHandler;
size = sizeof(msg);
msg.node.handler = pvd_qid;
msg.node.netver = net_cVersion;
msg.hdr.nid = gdbroot->my_node->nid;
msg.node.nod_oid = gdbroot->my_node->nod_oid;
msg.node.vol_oid = gdbroot->my_node->vol_oid;
net_Put(&sts, &tgt, &msg, net_eMsg_serverConnect, 0, size, pvd_procom->m_sid);
if (EVEN(sts))
errh_Error("Sending 'serverConnect' to %s (%s)\n%m",
np->name, cdh_NodeIdToString(NULL, np->nid, 0, 0), sts);
}
static void
sendServerConnectAll (
)
{
pwr_tStatus sts;
qcom_sNode node;
pwr_tNodeId nid;
gdb_sNode *np;
// Send to local node
gdb_ScopeLock {
np = (gdb_sNode *) hash_Search(NULL, gdbroot->nid_ht, &gdbroot->db->nid);
} gdb_ScopeUnlock;
sendServerConnect( np);
if ( pvd_procom->m_global) {
// Send to all other nodes...
for (nid = qcom_cNNid; qcom_NextNode(&sts, &node, nid); nid = node.nid) {
gdb_ScopeLock {
np = (gdb_sNode *) hash_Search(&sts, gdbroot->nid_ht, &node.nid);
} gdb_ScopeUnlock;
if (np == NULL)
continue;
if (node.flags.b.connected) {
sendServerConnect( np);
}
}
}
}
static void
pvd_SetObjectInfo (
qcom_sGet *get
)
{
pwr_tStatus sts;
void *p;
gdb_sNode *np;
int size;
cdh_uTypeId cid;
gdb_sClass *cp;
net_sSetObjectInfo *mp = (net_sSetObjectInfo *)get->data;
gdb_ScopeLock {
np = (gdb_sNode *) hash_Search(NULL, gdbroot->nid_ht, &get->sender.nid);
pwr_Assert(np != NULL);
} gdb_ScopeUnlock;
p = malloc( mp->aref.Size);
if (p != NULL) {
size = mp->aref.Size;
cid.pwr = mp->aref.Body;
cid.c.bix = 0; /* To get the class id. */
cp = (gdb_sClass *) hash_Search(&sts, gdbroot->cid_ht, &cid.pwr);
if (cp != NULL)
ndc_ConvertData(&sts, np, cp, &mp->aref, p, mp->info, (pwr_tUInt32 *)&size,
ndc_eOp_decode, mp->aref.Offset, 0);
}
pvd_procom->m_getmsg = get;
pvd_procom->m_provider->writeAttribute( pvd_procom, mp->aref.Objid.oix, mp->aref.Offset,
mp->aref.Size, (char *)p);
}
static void
pvd_GetObjectInfo (
qcom_sGet *get
)
{
net_sGetObjectInfo *mp = (net_sGetObjectInfo *)get->data;
pvd_procom->m_getmsg = get;
pvd_procom->m_provider->readAttribute( pvd_procom, mp->aref.Objid.oix, mp->aref.Offset,
mp->aref.Size);
}
static void
pvd_SubAdd (
qcom_sGet *get
)
{
pwr_tInt32 i;
pwr_tStatus sts;
net_sSubSpec *specp;
gdb_sNode *np;
net_sSubAdd *mp = (net_sSubAdd *)get->data;
gdb_AssumeUnlocked;
gdb_ScopeLock {
np = (gdb_sNode *) hash_Search(&sts, gdbroot->nid_ht, &get->sender.nid);
if (np == NULL) {
errh_Error("subsm_Add, node (%s), is not known",
cdh_NodeIdToString(NULL, get->sender.nid, 1, 0));
break;
}
} gdb_ScopeUnlock;
pvd_procom->m_getmsg = get;
specp = &mp->spec[0];
for (i=0; i < (int) mp->count; i++, specp++) {
/* For all entries in the message. */
psub sub;
sub.sid = specp->sid;
sub.nid = np->nid;
sub.sub_by_name = specp->sub_by_name;
sub.aref = specp->aref;
sub.dt = specp->dt;
pvd_procom->m_provider->subAssociateBuffer( pvd_procom, &sub.p, sub.aref.Objid.oix,
sub.aref.Offset, sub.aref.Size, sub.sid);
subkey k(sub.sid);
m_sublist[k] = sub;
}
}
static void
pvd_SubRemove (
qcom_sGet *get
)
{
net_sSubRemove *mp = (net_sSubRemove *) get->data;
pwr_tSubid *sp;
pvd_procom->m_getmsg = get;
sp = &mp->sid[0];
for ( int i = 0; i < (int)mp->count; i++) {
subkey k(*sp);
sublist_iterator it = m_sublist.find( k);
if ( it != m_sublist.end())
m_sublist.erase( it);
pvd_procom->m_provider->subDisassociateBuffer( pvd_procom, *sp);
sp++;
}
}
static pwr_tBoolean
pvd_SubSendBuffer ()
{
pwr_tStatus sts = 1;
net_sSubMessage *mp;
net_sSubData *dp;
gdb_sNode *np;
qcom_sQid tgt;
pwr_tUInt32 size;
pwr_tInt32 subdatahdrsize;
gdb_sClass *classp;
cdh_uTypeId cid;
int asize;
int totsize = 0;
int bufsubs_lc = 0;
static int buf_id = 1;
pwr_tNodeId subnid[100];
int subnid_cnt = 0;
pwr_tNodeId nid;
/* Fill in buffer */
// Get nodes
for ( sublist_iterator it = m_sublist.begin(); it != m_sublist.end(); it++) {
int found = 0;
for ( int j = 0; j < subnid_cnt; j++) {
if ( subnid[j] == it->second.nid) {
found = 1;
break;
}
}
if ( !found)
subnid[subnid_cnt++] = it->second.nid;
}
for ( int j = 0; j < subnid_cnt; j++) {
nid = subnid[j];
/* Build a buffer containing the update message */
totsize = 0;
bufsubs_lc = 0;
for ( sublist_iterator it = m_sublist.begin(); it != m_sublist.end(); it++) {
if ( it->second.nid == nid) {
totsize += it->second.aref.Size;
bufsubs_lc++;
}
}
subdatahdrsize = sizeof(*dp) - sizeof(dp->data);
size = totsize +
bufsubs_lc * subdatahdrsize + /* size of data hdrs */
sizeof(*mp) - sizeof(mp->subdata); /* size of msg hdr */
size = (size + 3) & ~3; /* Size up to nearest multiple of 4. */
mp = (net_sSubMessage *) calloc(1, size);
mp->count = 0;
dp = (net_sSubData *)&mp->subdata;
gdb_ScopeLock {
np = (gdb_sNode *) hash_Search(NULL, gdbroot->nid_ht, &nid);
if ( np == NULL) continue;
for ( sublist_iterator it = m_sublist.begin(); it != m_sublist.end(); it++) {
if ( it->second.nid != nid)
continue;
dp->sid = it->second.sid;
dp->size = it->second.aref.Size;
dp->sts = GDH__SUCCESS;
if (ODD(dp->sts)) {
asize = it->second.aref.Size;
cid.pwr = it->second.aref.Body;
cid.c.bix = 0; /* To get the class id. */
classp = (gdb_sClass *) hash_Search(&sts, gdbroot->cid_ht, &cid.pwr);
if (classp && it->second.p)
ndc_ConvertData(&dp->sts, np, classp, &it->second.aref, dp->data,
it->second.p, (pwr_tUInt32 *)&asize, ndc_eOp_encode,
it->second.aref.Offset, 0);
it->second.count++;
mp->count++;
}
/* Advance pointer to next sdata slot */
dp = (net_sSubData *)((pwr_tInt32)dp + it->second.aref.Size + subdatahdrsize);
}
} gdb_ScopeUnlock;
if ( !mp->count)
continue;
tgt.qix = net_cProcHandler;
tgt.nid = nid;
net_Put(&sts, &tgt, mp, net_eMsg_subData, buf_id++, size, pvd_procom->m_sid);
free(mp);
}
return 1;
}
void rt_procom::provideObjects( pwr_tStatus sts, vector<procom_obj>& ovect)
{
qcom_sPut put;
net_sObjectR *rsp;
net_sGobject *gop;
pwr_tUInt32 count = ovect.size();
pwr_tUInt32 pcount;
pwr_tUInt32 size;
int i;
net_sGobject g;
/* The parents must be first in the message, so the receiver can link
the cache objects. They must be in top-down-order. */
pcount = 0;
/* Build response message. */
size = sizeof(net_sObjectR) + count * sizeof(net_sGobject);
rsp = (net_sObjectR *) net_Alloc(&sts, &put, size, net_eMsg_objectR);
if (rsp == NULL) {
printf("NETH: could not allocate pams buffer for Cache send response, sts: %d\n", sts);
respondError(m_getmsg, g.oid, sts);
return;
}
gop = &rsp->g[0];
for ( i = 0; i < (int)ovect.size(); i++) {
/* Copy target object. */
g.oid.vid = m_vid;
g.oid.oix = ovect[i].oix;
g.flags.m = 0;
g.cid = ovect[i].cid;
cdh_ObjName( &g.f.name, ovect[i].name);
g.f.poid.oix = ovect[i].fthoix;
if ( ovect[i].oix)
g.f.poid.vid = m_vid;
else
g.f.poid.vid = 0;
g.sib.flink = ovect[i].fwsoix;
g.sib.blink = ovect[i].bwsoix;
if ( ovect[i].fchoix) {
g.soid.vid = m_vid;
g.soid.oix = ovect[i].fchoix;
g.flags.b.isParent = 1;
}
g.size = ovect[i].body_size;
*gop++ = g;
}
if ( m_getmsg->type.s == (qcom_eStype)net_eMsg_oidToObject) {
net_sOidToObject *mp = (net_sOidToObject *)m_getmsg->data;
rsp->oid = mp->oid;
}
else
rsp->oid = g.oid;
rsp->sts = GDH__SUCCESS;
rsp->count = count;
if (!net_Reply(&sts, m_getmsg, &put, 0))
errh_Bugcheck(sts, "net_Reply");
}
void rt_procom::provideAttr( pwr_tStatus sts, pwr_tOix oix, int bsize, void *buff)
{
net_sGetObjectInfoR *rmp;
qcom_sPut put;
net_sGetObjectInfo *mp = (net_sGetObjectInfo *)m_getmsg->data;
gdb_sNode *np;
int size;
cdh_uTypeId cid;
gdb_sClass *cp;
size = mp->aref.Size + sizeof(net_sGetObjectInfoR) - sizeof(rmp->info);
size = (size + 3) & ~3; /* Size up to nearest multiple of 4. */
rmp = (net_sGetObjectInfoR *)net_Alloc(&sts, &put, size, net_eMsg_getObjectInfoR);
if (EVEN(sts)) return;
gdb_ScopeLock {
np = (gdb_sNode *) hash_Search(NULL, gdbroot->nid_ht, &m_getmsg->sender.nid);
pwr_Assert(np != NULL);
} gdb_ScopeUnlock;
if (buff != NULL) {
size = mp->aref.Size;
cid.pwr = mp->aref.Body;
cid.c.bix = 0; /* To get the class id. */
cp = (gdb_sClass *) hash_Search(&sts, gdbroot->cid_ht, &cid.pwr);
if (cp != NULL)
ndc_ConvertData(&sts, np, cp, &mp->aref, rmp->info, buff, (pwr_tUInt32 *)&size,
ndc_eOp_encode, mp->aref.Offset, 0);
}
rmp->aref = mp->aref;
rmp->sts = sts;
rmp->size = mp->aref.Size;
net_Reply(&sts, m_getmsg, &put, 0);
}
void rt_procom::provideStatus( pwr_tStatus rsts)
{
pwr_tStatus sts;
switch( m_getmsg->type.s) {
case net_eMsg_getObjectInfo: {
qcom_sPut put;
net_sGetObjectInfoR *rmp;
net_sGetObjectInfo *mp = (net_sGetObjectInfo *)m_getmsg->data;
int size = mp->aref.Size + sizeof(net_sGetObjectInfoR) - sizeof(rmp->info);
size = (size + 3) & ~3; /* Size up to nearest multiple of 4. */
rmp = (net_sGetObjectInfoR *)net_Alloc(&sts, &put, size,
net_eMsg_getObjectInfoR);
if (EVEN(sts)) return;
rmp->aref = mp->aref;
rmp->sts = rsts;
rmp->size = mp->aref.Size;
net_Reply(&sts, m_getmsg, &put, 0);
break;
}
case net_eMsg_setObjectInfo: {
qcom_sPut put;
net_sSetObjectInfo *mp = (net_sSetObjectInfo *)m_getmsg->data;
net_sSetObjectInfoR *rmp = (net_sSetObjectInfoR *) net_Alloc(&sts,
&put, sizeof(*rmp), net_eMsg_setObjectInfoR);
if (EVEN(sts)) return;
rmp->aref = mp->aref;
rmp->sts = sts;
net_Reply(&sts, m_getmsg, &put, 0);
break;
}
case net_eMsg_oidToObject: {
respondError( m_getmsg, pwr_cNObjid, sts);
break;
}
default:
;
}
}
void rt_procom::flushNodes()
{
gdb_ScopeLock {
cvolcm_ExternVolumeFlush( gdbroot->my_node);
} gdb_ScopeUnlock;
// cvolcm_FlushNode(NULL, gdbroot->my_node);
// cvolsm_FlushNode(NULL, gdbroot->my_node);
// subc_ActivateList(&gdbroot->my_node->subc_lh, pwr_cNObjid);
// subc_ActivateList(&gdbroot->no_node->subc_lh, pwr_cNObjid);
}
/*
* Proview $Id: rt_procom.h,v 1.1 2006-09-14 14:16:07 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.
*/
#ifndef rt_procom_h
#define rt_procom_h
#include "co_procom.h"
#include "rt_qcom.h"
class rt_procom : public co_procom {
public:
errh_eAnix m_anix;
char m_name[32];
pwr_tSid m_sid;
pwr_tVid m_vid;
char m_volumename[32];
int m_global;
qcom_sGet *m_getmsg;
rt_procom( co_provider *p, errh_eAnix anix, char *name, pwr_tSid sid, pwr_tVid vid,
char *volumename, int global);
void init();
void mainLoop();
virtual ~rt_procom() {}
virtual void provideObjects( pwr_tStatus, vector<procom_obj>&);
virtual void provideObject( pwr_tStatus sts, pwr_tOix oix, pwr_tOix fthoix, pwr_tOix bwsoix,
pwr_tOix fwsoix, pwr_tOix fchoix, pwr_tOix lchoix, pwr_tCid cid,
char *name, char *longname) {}
virtual void provideBody( pwr_tStatus sts, pwr_tOix oix, int size, void *body) {}
virtual void provideAttr( pwr_tStatus sts, pwr_tOix oix, int size, void *buff);
virtual void provideStatus( pwr_tStatus sts);
virtual void flushNodes();
};
#endif
/*
* Proview $Id: rt_sancm.c,v 1.3 2006-03-20 07:17:55 claes Exp $
* Proview $Id: rt_sancm.c,v 1.4 2006-09-14 14:16:07 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -89,7 +89,7 @@ sancm_Add (
if (i >= count) {
ap->count = count;
gdb_Unlock;
net_Put(NULL, &tgt, ap, net_eMsg_sanAdd, 0, pwr_Offset(ap, sane[i]));
net_Put(NULL, &tgt, ap, net_eMsg_sanAdd, 0, pwr_Offset(ap, sane[i]), 0);
gdb_Lock;
i = 0;
}
......@@ -102,7 +102,7 @@ sancm_Add (
if (i > 0) {
ap->count = i;
gdb_Unlock;
net_Put(NULL, &tgt, ap, net_eMsg_sanAdd, 0, pwr_Offset(ap, sane[i]));
net_Put(NULL, &tgt, ap, net_eMsg_sanAdd, 0, pwr_Offset(ap, sane[i]), 0);
gdb_Lock;
}
......@@ -260,7 +260,7 @@ sancm_Remove (
if (i >= count) {
rp->count = count;
gdb_Unlock;
net_Put(NULL, &tgt, rp, net_eMsg_sanRemove, 0, pwr_Offset(rp, sid[i]));
net_Put(NULL, &tgt, rp, net_eMsg_sanRemove, 0, pwr_Offset(rp, sid[i]), 0);
gdb_Lock;
i = 0;
}
......@@ -273,7 +273,7 @@ sancm_Remove (
if (i > 0) {
rp->count = count;
gdb_Unlock;
net_Put(NULL, &tgt, rp, net_eMsg_sanRemove, 0, pwr_Offset(rp, sid[i]));
net_Put(NULL, &tgt, rp, net_eMsg_sanRemove, 0, pwr_Offset(rp, sid[i]), 0);
gdb_Lock;
}
......@@ -328,7 +328,7 @@ sancm_Update (
}
gdb_Unlock;
errh_Info("sancm_Update, sent removed count %d", rp->count);
net_Put(NULL, &tgt, rp, net_eMsg_sanRemove, 0, size);
net_Put(NULL, &tgt, rp, net_eMsg_sanRemove, 0, size, 0);
gdb_Lock;
free(rp);
}
......
/*
* Proview $Id: rt_sansm.c,v 1.3 2006-03-20 07:18:29 claes Exp $
* Proview $Id: rt_sansm.c,v 1.4 2006-09-14 14:16:07 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -347,7 +347,7 @@ sansm_Update (
#if 0
errh_Info("sansm_Update, put %d to %s", up->count, np->name);
#endif
net_Put(&sts, &tgt, up, net_eMsg_sanUpdate, 0, pwr_Offset(up, data[i]));
net_Put(&sts, &tgt, up, net_eMsg_sanUpdate, 0, pwr_Offset(up, data[i]), 0);
gdb_Lock;
if (EVEN(sts)) return 0;
......
/*
* Proview $Id: rt_subc.c,v 1.5 2006-03-20 07:22:35 claes Exp $
* Proview $Id: rt_subc.c,v 1.6 2006-09-14 14:16:07 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -448,10 +448,6 @@ subc_ActivateList (
sAdd *aep;
gdb_AssumeLocked;
tgt.qix = net_cProcHandler;
/* Test each client. If existing object, fill in nid field
and move the client to the appropriate nodes's subc_lh list. Turn
on timeouts. Put request in subadd message buffer.
......@@ -536,12 +532,12 @@ subc_ActivateList (
/* The message buffer is full and must be sent. */
tgt.nid = aep->nid;
tgt = np->handler;
pwr_Assert(tgt.nid != pwr_cNNodeId);
gdb_Unlock;
net_Put(NULL, &tgt, aep->msg, net_eMsg_subAdd, 0, pwr_Offset(aep->msg, spec[aep->msg->count]));
net_Put(NULL, &tgt, aep->msg, net_eMsg_subAdd, 0, pwr_Offset(aep->msg, spec[aep->msg->count]), 0);
gdb_Lock;
......@@ -586,7 +582,7 @@ subc_ActivateList (
gdb_Unlock;
net_Put(NULL, &tgt, rep->msg, net_eMsg_subRemove, 0, pwr_Offset(rep->msg, sid[rep->msg->count]));
net_Put(NULL, &tgt, rep->msg, net_eMsg_subRemove, 0, pwr_Offset(rep->msg, sid[rep->msg->count]), 0);
gdb_Lock;
......@@ -611,7 +607,7 @@ subc_ActivateList (
if (rep->msg->count > 0) {
tgt.nid = rep->nid;
pwr_Assert(tgt.nid != pwr_cNNodeId);
net_Put(NULL, &tgt, rep->msg, net_eMsg_subRemove, 0, pwr_Offset(rep->msg, sid[rep->msg->count]));
net_Put(NULL, &tgt, rep->msg, net_eMsg_subRemove, 0, pwr_Offset(rep->msg, sid[rep->msg->count]), 0);
}
free(rep->msg);
}
......@@ -622,7 +618,7 @@ subc_ActivateList (
if (aep->msg->count > 0) {
tgt.nid = aep->nid;
pwr_Assert(tgt.nid != pwr_cNNodeId);
net_Put(NULL, &tgt, aep->msg, net_eMsg_subAdd, 0, pwr_Offset(aep->msg, spec[aep->msg->count]));
net_Put(NULL, &tgt, aep->msg, net_eMsg_subAdd, 0, pwr_Offset(aep->msg, spec[aep->msg->count]), 0);
}
free(aep->msg);
}
......@@ -700,7 +696,7 @@ subc_CancelList (
gdb_Unlock;
net_Put(NULL, &tgt, rep->msg, net_eMsg_subRemove, 0, pwr_Offset(rep->msg, sid[rep->msg->count]));
net_Put(NULL, &tgt, rep->msg, net_eMsg_subRemove, 0, pwr_Offset(rep->msg, sid[rep->msg->count]), 0);
gdb_Lock;
......@@ -720,7 +716,7 @@ subc_CancelList (
if (rep->msg != NULL) {
if (rep->msg->count > 0) {
tgt.nid = rep->nid;
net_Put(NULL, &tgt, rep->msg, net_eMsg_subRemove, 0, pwr_Offset(rep->msg, sid[rep->msg->count]));
net_Put(NULL, &tgt, rep->msg, net_eMsg_subRemove, 0, pwr_Offset(rep->msg, sid[rep->msg->count]), 0);
}
free(rep->msg);
}
......
/*
* Proview $Id: rt_subcm.c,v 1.6 2006-03-20 07:21:22 claes Exp $
* Proview $Id: rt_subcm.c,v 1.7 2006-09-14 14:16:07 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -259,10 +259,12 @@ subcm_Data (
gdbroot->db->subm_lc--;
pool_Free(NULL, gdbroot->pool, mp);
}
} gdb_ScopeUnlock;
if (rp != NULL) {
net_Put(NULL, &tgt, rp, net_eMsg_subRemove, 0, pwr_Offset(rp, sid[rp->count]));
if (rp != NULL) {
tgt = np->handler;
net_Put(NULL, &tgt, rp, net_eMsg_subRemove, 0, pwr_Offset(rp, sid[rp->count]), 0);
#if 0
errh_Info("Removed %d subscriptions", rp->count - 1);
#endif
......
/*
* Proview $Id: rt_subsm.c,v 1.7 2006-03-20 07:26:51 claes Exp $
* Proview $Id: rt_subsm.c,v 1.8 2006-09-14 14:16:07 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -410,7 +410,7 @@ subsm_SendBuffer (
gdb_Unlock;
net_Put(&sts, &tgt, mp, net_eMsg_subData, bp->buf_id, size);
net_Put(&sts, &tgt, mp, net_eMsg_subData, bp->buf_id, size, 0);
gdb_Lock;
......
/*
* Proview $Id: rt_vol.h,v 1.4 2005-10-07 05:57:28 claes Exp $
* Proview $Id: rt_vol.h,v 1.5 2006-09-14 14:16:07 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -210,7 +210,7 @@ typedef union {
typedef union {
pwr_tBitMask m;
pwr_32Bits (
pwr_Bits( private , 1),
pwr_Bits( privat , 1),
pwr_Bits( native , 1),
pwr_Bits( fileCached , 1),
pwr_Bits( netCached , 1),
......
!
! Proview $Id: rs_remote_msg.msg,v 1.2 2005-09-01 14:58:00 claes Exp $
! Proview $Id: rs_remote_msg.msg,v 1.3 2006-09-14 14:16:07 claes Exp $
! Copyright (C) 2005 SSAB Oxelsund AB.
!
! This program is free software; you can redistribute it and/or
......@@ -62,3 +62,5 @@ udplinkdown <Remote UDP/IP link down '%s'> /info
udplinkup <Remote UDP/IP link up '%s'> /info
udpunknown <UDP message from unknown ip-address '%s' received> /info
udpweirdheader <UDP message with illegal header received> /info
disorder <Message disorder> /error
disabled <Transport disabled> /error
!
! Proview $Id: pwrs_c_externvolume.wb_load,v 1.2 2005-09-01 14:58:03 claes Exp $
! Proview $Id: pwrs_c_externvolume.wb_load,v 1.3 2006-09-14 14:16:07 claes Exp $
! Copyright (C) 2005 SSAB Oxelsund AB.
!
! This program is free software; you can redistribute it and/or
......@@ -26,7 +26,6 @@ SObject pwrs:Class
Object $ExternVolume $ClassDef pwr_eCix_ExternVolume
Body SysBody
Attr Flags |= pwr_mClassDef_System
Attr Flags |= pwr_mClassDef_DevOnly
Attr Flags |= pwr_mClassDef_TopObject
EndBody
Object SysBody $ObjBodyDef 1
......
......@@ -4,7 +4,7 @@ link_rule_mk := 1
ifeq ($(export_type),exp)
link = $(ldxx) $(explinkflags) $(domap) -o $(export_exe) \
$(export_obj) $(objects) $(wb_msg_eobjs) $(rt_msg_eobjs) \
$(pwr_eobj)/rt_io_user.o $(pwr_obj)/wb_provider.o \
$(pwr_eobj)/rt_io_user.o $(pwr_obj)/wb_procom.o \
-L/usr/X11R6/lib -L/usr/local/BerkeleyDB.4.0/lib \
-L/opt/gnome/lib \
-lpwr_wb -lpwr_rt -lpwr_ge -lpwr_flow -lpwr_glow -lpwr_co \
......@@ -14,7 +14,7 @@ ifeq ($(export_type),exp)
else
link = $(ldxx) $(elinkflags) $(domap) -o $(export_exe) \
$(export_obj) $(objects) $(wb_msg_eobjs) $(rt_msg_eobjs) \
$(pwr_eobj)/rt_io_user.o $(pwr_obj)/wb_provider.o \
$(pwr_eobj)/rt_io_user.o $(pwr_obj)/wb_procom.o \
-L/usr/X11R6/lib -L/usr/local/BerkeleyDB.4.0/lib \
-L/opt/gnome/lib \
-lpwr_wb -lpwr_rt -lpwr_ge -lpwr_flow -lpwr_glow -lpwr_co \
......
/*
* Proview $Id: wb_procom.cpp,v 1.1 2006-09-14 14:16:20 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.
*/
extern "C" {
#include <unistd.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/msg.h>
#include <fcntl.h>
#include <string.h>
#include <stdio.h>
}
extern "C" {
#include "pwr.h"
#include "pwr_class.h"
#include "co_cdh.h"
#include "wb_ldh_msg.h"
}
#include "wb_vext.h"
#include "wb_procom.h"
void wb_procom::put( vext_sAMsg *msg, int size, pwr_tStatus *sts)
{
*sts = LDH__SUCCESS;
msg->Any.message_type = 1;
switch ( m_type) {
case procom_eType_Ipc:
if ( msgsnd( m_msgsndid, (void *)msg, size, 0) == -1) {
*sts = LDH__MSGSND;
return;
}
case procom_eType_Local:
memcpy( &m_msg, msg, sizeof(m_msg));
break;
}
}
void wb_procom::receive( vext_sQMsg *msg, int size, pwr_tStatus *sts)
{
if ( !m_connected) {
key_t key;
int fd = -1;
fd = open( m_key, O_RDWR | O_CREAT, 0777);
if ( fd < 0) {
*sts = LDH__NOPROV;
return;
}
close( fd);
key = ftok( m_key, 0);
m_msgrcvid = msgget( (key_t)key, 0666 | IPC_CREAT);
if ( m_msgrcvid == -1) {
*sts = LDH__MSGGET;
return;
}
m_msgsndid = msgget( (key_t)(key + 1), 0666 | IPC_CREAT);
if ( m_msgsndid == -1) {
*sts = LDH__MSGGET;
return;
}
m_connected = 1;
}
if ( msgrcv( m_msgrcvid, (void *)msg, size, 0, 0) == -1) {
*sts = LDH__MSGRCV;
return;
}
*sts = LDH__SUCCESS;
}
void wb_procom::provideObject( pwr_tStatus sts, pwr_tOix oix, pwr_tOix fthoix, pwr_tOix bwsoix,
pwr_tOix fwsoix, pwr_tOix fchoix, pwr_tOix lchoix, pwr_tCid cid,
char *name, char *longname)
{
vext_sAMsg amsg;
pwr_tStatus asts;
amsg.Object.Type = vext_eMsgType_Object;
amsg.Object.Status = sts;
amsg.Object.oix = oix;
amsg.Object.fthoix = fthoix;
amsg.Object.bwsoix = bwsoix;
amsg.Object.fwsoix = fwsoix;
amsg.Object.fchoix = fchoix;
amsg.Object.lchoix = lchoix;
amsg.Object.cid = cid;
if ( ODD(sts)) {
strcpy( amsg.Object.name, name);
strcpy( amsg.Object.longname, longname);
}
put( &amsg, sizeof(amsg), &asts);
}
void wb_procom::provideBody( pwr_tStatus sts, pwr_tOix oix, int size, void *body)
{
vext_sAMsg amsg;
pwr_tStatus asts;
amsg.Object.Type = vext_eMsgType_ObjectBody;
amsg.ObjectBody.Status = sts;
amsg.ObjectBody.oix = oix;
if ( (int)sizeof(amsg.ObjectBody.body) < size)
size = sizeof(amsg.ObjectBody.body);
amsg.ObjectBody.size = size;
if ( ODD(sts))
memcpy( amsg.ObjectBody.body, body, size);
put( &amsg, sizeof(amsg), &asts);
}
void wb_procom::provideStatus( pwr_tStatus sts)
{
vext_sAMsg amsg;
pwr_tStatus asts;
amsg.Object.Type = vext_eMsgType_Status;
amsg.Any.Status = sts;
put( &amsg, sizeof(amsg), &asts);
}
void wb_procom::dispatch( vext_sQMsg *qmsg)
{
switch( qmsg->Any.Type) {
case vext_eMsgType_Object:
// printf( "Object\n");
m_provider->object( this);
break;
case vext_eMsgType_ObjectOid:
// printf( "ObjectOid %d\n", qmsg->Oid.Oix);
m_provider->objectOid( this, qmsg->Oid.Oix);
break;
case vext_eMsgType_ObjectBody:
// printf( "ObjectBody %d\n", qmsg->Oid.Oix);
m_provider->objectBody( this, qmsg->Oid.Oix);
break;
case vext_eMsgType_ObjectName:
// printf( "ObjectName %s\n", qmsg->ObjectName.Name);
m_provider->objectName( this, qmsg->ObjectName.Name);
break;
case vext_eMsgType_CreateObject:
// printf( "CreateObject %s\n", qmsg->CreateObject.Name);
m_provider->createObject( this, qmsg->CreateObject.DestOix, qmsg->CreateObject.DestType,
qmsg->CreateObject.Cid, qmsg->CreateObject.Name);
break;
case vext_eMsgType_MoveObject:
// printf( "MoveObject %d\n", qmsg->Oid.Oix);
m_provider->moveObject( this, qmsg->MoveObject.Oix, qmsg->MoveObject.DestOix,
qmsg->MoveObject.DestType);
break;
case vext_eMsgType_CopyObject:
// printf( "CopyObject %d\n", qmsg->Oid.Oix);
m_provider->copyObject( this, qmsg->CopyObject.Oix, qmsg->CopyObject.DestOix,
qmsg->CopyObject.DestType, qmsg->CopyObject.Name);
break;
case vext_eMsgType_DeleteObject:
// printf( "DeleteObject %d\n", qmsg->Oid.Oix);
m_provider->deleteObject( this, qmsg->DeleteObject.Oix);
break;
case vext_eMsgType_DeleteFamily:
// printf( "DeleteFamily %d\n", qmsg->Oid.Oix);
m_provider->deleteFamily( this, qmsg->DeleteFamily.Oix);
break;
case vext_eMsgType_RenameObject:
// printf( "RenameObject %d\n", qmsg->Oid.Oix);
m_provider->renameObject( this, qmsg->RenameObject.Oix, qmsg->RenameObject.Name);
break;
case vext_eMsgType_WriteAttr:
// printf( "WriteAttr %d\n", qmsg->Oid.Oix);
m_provider->writeAttribute( this, qmsg->WriteAttr.Oix, qmsg->WriteAttr.Offset,
qmsg->WriteAttr.Size, qmsg->WriteAttr.Buffer);
break;
case vext_eMsgType_Commit:
// printf( "Commit\n");
m_provider->commit( this);
break;
case vext_eMsgType_Abort:
// printf( "Abort\n");
m_provider->abort( this);
break;
default:
;
}
}
int wb_procom::lmsgsnd( int msgid, const void *msg_ptr, size_t msg_sz, int msgflg)
{
dispatch( (vext_sQMsg *)msg_ptr);
return 0;
}
int wb_procom::lmsgrcv( int msgid, const void *msg_ptr, size_t msg_sz, int msgtype,
int msgflg)
{
memcpy( (void *)msg_ptr, &m_msg, sizeof(m_msg));
return 0;
}
void wb_procom::mainloop()
{
vext_sQMsg qmsg;
pwr_tStatus sts;
for (;;) {
receive( &qmsg, sizeof(qmsg), &sts);
dispatch( &qmsg);
}
}
/*
* Proview $Id: wb_provider.h,v 1.4 2005-09-22 09:45:39 claes Exp $
* Proview $Id: wb_procom.h,v 1.1 2006-09-14 14:16:20 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -17,51 +17,26 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef wb_provider_h
#define wb_provider_h
#ifndef wb_procom_h
#define wb_procom_h
#include "co_procom.h"
#include "wb_vext.h"
class wb_procom;
class wb_provider {
public:
virtual ~wb_provider() {}
virtual void object( wb_procom *pcom) {}
virtual void objectOid( wb_procom *pcom, pwr_tOix oix) {}
virtual void objectName( wb_procom *pcom, char *name) {}
virtual void objectBody( wb_procom *pcom, pwr_tOix oix) {}
virtual void createObject( wb_procom *pcom, pwr_tOix destoix, int desttype,
pwr_tCid cid, char *name) {}
virtual void moveObject( wb_procom *pcom, pwr_tOix oix, pwr_tOix destoix,
int desttype) {}
virtual void copyObject( wb_procom *pcom, pwr_tOix oix, pwr_tOix destoix, int desttype,
char *name) {}
virtual void deleteObject( wb_procom *pcom, pwr_tOix oix) {}
virtual void deleteFamily( wb_procom *pcom, pwr_tOix oix) {}
virtual void renameObject( wb_procom *pcom, pwr_tOix oix, char *name) {}
virtual void writeAttribute( wb_procom *pcom, pwr_tOix oix, unsigned int offset,
unsigned int size, char *buffer) {}
virtual void commit( wb_procom *pcom) {}
virtual void abort( wb_procom *pcom) {}
};
class wb_procom
class wb_procom : public co_procom
{
char m_key[200];
int m_connected;
int m_msgsndid;
int m_msgrcvid;
procom_eType type;
wb_provider *m_provider;
vext_sAMsg m_msg;
procom_eType m_type;
public:
wb_procom( char *key, wb_provider *p, procom_eType type) :
m_connected(0), m_provider(p), m_type( type)
wb_procom( char *key, co_provider *p, procom_eType type) :
co_procom( p), m_connected(0), m_type( type)
{
strcpy( m_key, key);
}
......
/*
* Proview $Id: wb_pvd_gvl.cpp,v 1.3 2005-11-22 12:24:50 claes Exp $
* Proview $Id: wb_pvd_gvl.cpp,v 1.4 2006-09-14 14:16:20 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -97,7 +97,7 @@ void wb_pvd_gvl::load( pwr_tStatus *rsts)
*rsts = LDH__SUCCESS;
// Create Root object
pitem rootitem;
procom_obj rootitem;
strcpy( rootitem.name, "GlobalVolumeList");
rootitem.cid = pwr_eClass_Hier;
rootitem.oix = 0;
......@@ -133,7 +133,7 @@ void wb_pvd_gvl::load( pwr_tStatus *rsts)
continue;
}
pitem plantitem;
procom_obj plantitem;
strcpy( plantitem.name, line_item[1]);
plantitem.cid = pwr_eClass_Hier;
plantitem.oix = next_oix++;
......@@ -175,7 +175,7 @@ void wb_pvd_gvl::load( pwr_tStatus *rsts)
continue;
}
pitem volitem;
procom_obj volitem;
strcpy( volitem.name, line_item[0]);
volitem.body_size = sizeof(pwr_sClass_VolumeReg);
......
/*
* Proview $Id: wb_pvd_gvl.h,v 1.1 2005-09-20 13:14:28 claes Exp $
* Proview $Id: wb_pvd_gvl.h,v 1.2 2006-09-14 14:16:20 claes Exp $
* Copyright (C) 2005 SSAB Oxelösund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -20,9 +20,9 @@
#ifndef wb_pvd_gvl_h
#define wb_pvd_gvl_h
#include "wb_pvd_file.h"
#include "co_pvd_file.h"
class wb_pvd_gvl : public wb_pvd_file {
class wb_pvd_gvl : public co_pvd_file {
public:
wb_pvd_gvl()
{
......
/*
* Proview $Id: wb_pvd_pl.cpp,v 1.5 2005-11-22 12:25:12 claes Exp $
* Proview $Id: wb_pvd_pl.cpp,v 1.6 2006-09-14 14:16:20 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -79,7 +79,7 @@ static char *pwrp_status_to_string( int value)
return str;
}
void wb_pvd_pl::writeAttribute( wb_procom *pcom, pwr_tOix oix, unsigned int offset,
void wb_pvd_pl::writeAttribute( co_procom *pcom, pwr_tOix oix, unsigned int offset,
unsigned int size, char *buffer)
{
if ( oix >= m_list.size() || oix <= 0) {
......@@ -103,15 +103,15 @@ void wb_pvd_pl::writeAttribute( wb_procom *pcom, pwr_tOix oix, unsigned int offs
default: ;
}
wb_pvd_file::writeAttribute( pcom, oix, offset, size, buffer);
co_pvd_file::writeAttribute( pcom, oix, offset, size, buffer);
}
void wb_pvd_pl::createObject( wb_procom *pcom, pwr_tOix destoix, int desttype,
void wb_pvd_pl::createObject( co_procom *pcom, pwr_tOix destoix, int desttype,
pwr_tCid cid, char *name)
{
pwr_tOix oix = next_oix;
wb_pvd_file::createObject( pcom, destoix, desttype, cid, name);
co_pvd_file::createObject( pcom, destoix, desttype, cid, name);
switch ( cid) {
case pwr_cClass_ProjectReg: {
......@@ -188,10 +188,10 @@ bool wb_pvd_pl::check_list( pwr_tStatus *sts)
oid.oix = m_list[i].oix;
oid.vid = ldh_cProjectListVolume;
if ( m_list[i].flags & pitem_mFlags_Deleted &&
!(m_list[i].flags & pitem_mFlags_Created)) {
if ( m_list[i].flags & procom_obj_mFlags_Deleted &&
!(m_list[i].flags & procom_obj_mFlags_Created)) {
}
else if ( !(m_list[i].flags & pitem_mFlags_Deleted)) {
else if ( !(m_list[i].flags & procom_obj_mFlags_Deleted)) {
if ( strcmp( body->Path, "") == 0) {
sprintf( msg, "Path is missing, in object %s", longname(m_list[i].oix));
......@@ -217,15 +217,15 @@ bool wb_pvd_pl::check_list( pwr_tStatus *sts)
oid.oix = m_list[i].oix;
oid.vid = ldh_cProjectListVolume;
if ( m_list[i].flags & pitem_mFlags_Deleted &&
!(m_list[i].flags & pitem_mFlags_Created)) {
if ( m_list[i].flags & procom_obj_mFlags_Deleted &&
!(m_list[i].flags & procom_obj_mFlags_Created)) {
// Project deleted
sprintf( msg, "delete project %s with file tree and databases\n", body->Project);
if ( strlen(text) + strlen(msg) < sizeof(text))
strcat( text, msg);
actions_found++;
}
else if ( !(m_list[i].flags & pitem_mFlags_Deleted)) {
else if ( !(m_list[i].flags & procom_obj_mFlags_Deleted)) {
if ( strcmp( body->Project, "") == 0) {
sprintf( msg, "Project is missing, in object %s", longname(m_list[i].oix));
......@@ -246,7 +246,7 @@ bool wb_pvd_pl::check_list( pwr_tStatus *sts)
MsgWindow::message('E', msg, msgw_ePop_No, oid);
error_cnt++;
}
if ( m_list[i].flags & pitem_mFlags_Created) {
if ( m_list[i].flags & procom_obj_mFlags_Created) {
if ( strcmp( body->CopyFrom, "") == 0) {
// Create project
// Check destination path
......@@ -346,8 +346,8 @@ void wb_pvd_pl::process_list( pwr_tStatus *sts)
case pwr_cClass_ProjectReg: {
pwr_sClass_ProjectReg *body = (pwr_sClass_ProjectReg *)m_list[i].body;
if ( m_list[i].flags & pitem_mFlags_Deleted &&
!(m_list[i].flags & pitem_mFlags_Created)) {
if ( m_list[i].flags & procom_obj_mFlags_Deleted &&
!(m_list[i].flags & procom_obj_mFlags_Created)) {
printf( "Project deleted %s\n", longname(i));
sprintf( cmd, "pwrp_env.sh delete project %s noconfirm",
......@@ -360,8 +360,8 @@ void wb_pvd_pl::process_list( pwr_tStatus *sts)
return;
}
}
else if ( m_list[i].flags & pitem_mFlags_Created &&
!(m_list[i].flags & pitem_mFlags_Deleted)) {
else if ( m_list[i].flags & procom_obj_mFlags_Created &&
!(m_list[i].flags & procom_obj_mFlags_Deleted)) {
if ( strcmp( body->CopyFrom, "") == 0) {
printf( "Project created %s\n", longname(i));
......@@ -389,7 +389,7 @@ void wb_pvd_pl::process_list( pwr_tStatus *sts)
}
}
}
else if ( !(m_list[i].flags & pitem_mFlags_Deleted)) {
else if ( !(m_list[i].flags & procom_obj_mFlags_Deleted)) {
pwr_sClass_ProjectReg *body = (pwr_sClass_ProjectReg *)m_list[i].body;
pwr_sClass_ProjectReg *origbody = (pwr_sClass_ProjectReg *)m_list[i].userdata;
......@@ -439,14 +439,14 @@ void wb_pvd_pl::save_list( pwr_tStatus *sts)
// Disable deletet objects
for ( int i = 0; i < (int) m_list.size(); i++) {
if ( m_list[i].flags & pitem_mFlags_Deleted)
if ( m_list[i].flags & procom_obj_mFlags_Deleted)
m_list[i].flags |= pl_mFlags_Disabled;
}
}
void wb_pvd_pl::save_item( pwr_tOix oix, ofstream& of)
{
if ( m_list[oix].flags & pitem_mFlags_Deleted)
if ( m_list[oix].flags & procom_obj_mFlags_Deleted)
return;
m_list[oix].flags = 0;
......@@ -507,7 +507,7 @@ void wb_pvd_pl::load( pwr_tStatus *rsts)
// Create Root object
pitem rootitem;
procom_obj rootitem;
strcpy( rootitem.name, "ProjectList");
rootitem.cid = pwr_eClass_Hier;
rootitem.oix = 0;
......@@ -516,7 +516,7 @@ void wb_pvd_pl::load( pwr_tStatus *rsts)
menu_cnt++;
// Create Root for BaseReg objects
pitem brootitem;
procom_obj brootitem;
strcpy( brootitem.name, "Bases");
brootitem.cid = pwr_eClass_Hier;
brootitem.oix = next_oix++;
......@@ -553,7 +553,7 @@ void wb_pvd_pl::load( pwr_tStatus *rsts)
continue;
}
pitem hieritem;
procom_obj hieritem;
strcpy( hieritem.name, line_item[1]);
hieritem.cid = pwr_eClass_Hier;
hieritem.oix = next_oix++;
......@@ -597,7 +597,7 @@ void wb_pvd_pl::load( pwr_tStatus *rsts)
continue;
}
pitem baseitem;
procom_obj baseitem;
strcpy( baseitem.name, basename(line_item[1]));
baseitem.cid = pwr_cClass_BaseReg;
baseitem.oix = next_oix++;
......@@ -638,7 +638,7 @@ void wb_pvd_pl::load( pwr_tStatus *rsts)
menu_stack[menu_cnt++] = hieroix;
}
pitem projitem;
procom_obj projitem;
if ( (s = strrchr( line_item[3], '-')))
strcpy( projitem.name, s + 1);
else
......@@ -698,7 +698,7 @@ bool wb_pvd_pl::create_hier( char *hier, pwr_tOix *oix)
// Check if name exist
if ( !find( fthoix, segment_name[i], &ix)) {
// Create this hierarchy object
pitem hieritem;
procom_obj hieritem;
strcpy( hieritem.name, segment_name[i]);
hieritem.cid = pwr_eClass_Hier;
hieritem.oix = next_oix++;
......
/*
* Proview $Id: wb_pvd_pl.h,v 1.2 2005-10-25 12:04:25 claes Exp $
* Proview $Id: wb_pvd_pl.h,v 1.3 2006-09-14 14:16:20 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -20,7 +20,7 @@
#ifndef wb_pvd_pl_h
#define wb_pvd_pl_h
#include "wb_pvd_file.h"
#include "co_pvd_file.h"
typedef enum {
pl_mFlags_ProjectModified = 1 << 16,
......@@ -28,16 +28,16 @@ typedef enum {
pl_mFlags_Disabled = 1 << 18
} pl_mFlags;
class wb_pvd_pl : public wb_pvd_file {
class wb_pvd_pl : public co_pvd_file {
public:
wb_pvd_pl()
{
pwr_tStatus sts;
load( &sts);
}
void writeAttribute( wb_procom *pcom, pwr_tOix oix, unsigned int offset,
void writeAttribute( co_procom *pcom, pwr_tOix oix, unsigned int offset,
unsigned int size, char *buffer);
void createObject( wb_procom *pcom, pwr_tOix destoix, int desttype,
void createObject( co_procom *pcom, pwr_tOix destoix, int desttype,
pwr_tCid cid, char *name);
void load( pwr_tStatus *sts);
void save( pwr_tStatus *sts);
......
/*
* Proview $Id: wb_vrepext.cpp,v 1.6 2005-11-22 12:28:18 claes Exp $
* Proview $Id: wb_vrepext.cpp,v 1.7 2006-09-14 14:16:20 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -45,7 +45,7 @@
#include "wb_volume.h"
#include "pwr_baseclasses.h"
#include "wb_pvd_gvl.h"
#include "wb_pvd_udb.h"
#include "co_pvd_udb.h"
#include "wb_pvd_pl.h"
extern "C" {
#include "co_dcli.h"
......@@ -84,7 +84,7 @@ wb_vrepext::wb_vrepext( wb_erep *erep, pwr_tVid vid, char *name, char *provider)
}
else if ( cdh_NoCaseStrcmp( provider, "UserDatabase") == 0) {
m_ptype = procom_eType_Local;
m_provider = new wb_pvd_udb();
m_provider = new co_pvd_udb();
m_procom = new wb_procom( provider, m_provider, procom_eType_Local);
}
}
......
/*
* Proview $Id: wb_vrepext.h,v 1.8 2006-05-11 07:12:20 claes Exp $
* Proview $Id: wb_vrepext.h,v 1.9 2006-09-14 14:16:20 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -29,7 +29,8 @@
#include "co_dbs.h"
#include "wb_import.h"
#include "wb_vext.h"
#include "wb_provider.h"
#include "co_provider.h"
#include "wb_procom.h"
#include "wb_cdef.h"
class wb_vrepext;
......@@ -145,7 +146,7 @@ class wb_vrepext : public wb_vrep
int m_msgrcvid;
ext_object m_cashe;
wb_procom *m_procom;
wb_provider *m_provider;
co_provider *m_provider;
procom_eType m_ptype;
public:
......
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