Commit 73e1539e authored by claes's avatar claes

*** empty log message ***

parent a3085a6c
/*
* Proview $Id: opc_provider.cpp,v 1.1 2007-03-01 09:12:54 claes Exp $
* Proview $Id: opc_provider.cpp,v 1.2 2007-03-02 08:52:20 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -33,6 +33,7 @@
#include "rt_gdh_msg.h"
#include "co_cdh.h"
#include "co_dcli.h"
#include "pwr_opcclasses.h"
#include "opc_soap_H.h"
#include "Service.nsmap"
......@@ -52,9 +53,182 @@ void opc_provider::object( co_procom *pcom)
objectOid( pcom, m_list[0].fchoix);
}
void opc_provider::insert_object( pwr_tOix fth, pwr_tOix bws, ns1__BrowseElement *element,
int first, int last, int load_children)
{
procom_obj o;
strcpy( o.name, element->Name->c_str());
o.oix = next_oix++;
o.fthoix = fth;
if ( !element->IsItem) {
o.cid = pwr_cClass_Opc_Hier;
}
else {
if ( element->Properties.size() &&
element->Properties[0]->Name == "dataType") {
if ( strcmp( element->Properties[0]->Value, "string") == 0) {
o.cid = pwr_cClass_Opc_String;
o.body_size = sizeof(pwr_sClass_Opc_String);
o.body = calloc( 1, o.body_size);
}
else if ( strcmp( element->Properties[0]->Value, "boolean") == 0) {
o.cid = pwr_cClass_Opc_Boolean;
o.body_size = sizeof(pwr_sClass_Opc_Boolean);
o.body = calloc( 1, o.body_size);
}
else if ( strcmp( element->Properties[0]->Value, "float") == 0) {
o.cid = pwr_cClass_Opc_Float;
o.body_size = sizeof(pwr_sClass_Opc_Float);
o.body = calloc( 1, o.body_size);
}
else if ( strcmp( element->Properties[0]->Value, "double") == 0) {
o.cid = pwr_cClass_Opc_Double;
o.body_size = sizeof(pwr_sClass_Opc_Double);
o.body = calloc( 1, o.body_size);
}
else if ( strcmp( element->Properties[0]->Value, "double") == 0) {
o.cid = pwr_cClass_Opc_Double;
o.body_size = sizeof(pwr_sClass_Opc_Double);
o.body = calloc( 1, o.body_size);
}
else if ( strcmp( element->Properties[0]->Value, "decimal") == 0) {
o.cid = pwr_cClass_Opc_Decimal;
o.body_size = sizeof(pwr_sClass_Opc_Decimal);
o.body = calloc( 1, o.body_size);
}
else if ( strcmp( element->Properties[0]->Value, "int") == 0) {
o.cid = pwr_cClass_Opc_Int;
o.body_size = sizeof(pwr_sClass_Opc_Int);
o.body = calloc( 1, o.body_size);
}
else if ( strcmp( element->Properties[0]->Value, "short") == 0) {
o.cid = pwr_cClass_Opc_Short;
o.body_size = sizeof(pwr_sClass_Opc_Short);
o.body = calloc( 1, o.body_size);
}
else if ( strcmp( element->Properties[0]->Value, "byte") == 0) {
o.cid = pwr_cClass_Opc_Byte;
o.body_size = sizeof(pwr_sClass_Opc_Byte);
o.body = calloc( 1, o.body_size);
}
else if ( strcmp( element->Properties[0]->Value, "unsignedLong") == 0) {
o.cid = pwr_cClass_Opc_UnsignedLong;
o.body_size = sizeof(pwr_sClass_Opc_UnsignedLong);
o.body = calloc( 1, o.body_size);
}
else if ( strcmp( element->Properties[0]->Value, "unsignedInt") == 0) {
o.cid = pwr_cClass_Opc_UnsignedInt;
o.body_size = sizeof(pwr_sClass_Opc_UnsignedInt);
o.body = calloc( 1, o.body_size);
}
else if ( strcmp( element->Properties[0]->Value, "unsignedShort") == 0) {
o.cid = pwr_cClass_Opc_UnsignedShort;
o.body_size = sizeof(pwr_sClass_Opc_UnsignedShort);
o.body = calloc( 1, o.body_size);
}
else if ( strcmp( element->Properties[0]->Value, "unsignedByte") == 0) {
o.cid = pwr_cClass_Opc_UnsignedByte;
o.body_size = sizeof(pwr_sClass_Opc_UnsignedByte);
o.body = calloc( 1, o.body_size);
}
else if ( strcmp( element->Properties[0]->Value, "base64Binary") == 0) {
o.cid = pwr_cClass_Opc_Base64Binary;
o.body_size = sizeof(pwr_sClass_Opc_Base64Binary);
o.body = calloc( 1, o.body_size);
}
else if ( strcmp( element->Properties[0]->Value, "dateTime") == 0) {
o.cid = pwr_cClass_Opc_DateTime;
o.body_size = sizeof(pwr_sClass_Opc_DateTime);
o.body = calloc( 1, o.body_size);
}
else if ( strcmp( element->Properties[0]->Value, "time") == 0) {
o.cid = pwr_cClass_Opc_Time;
o.body_size = sizeof(pwr_sClass_Opc_Time);
o.body = calloc( 1, o.body_size);
}
else if ( strcmp( element->Properties[0]->Value, "date") == 0) {
o.cid = pwr_cClass_Opc_Date;
o.body_size = sizeof(pwr_sClass_Opc_Date);
o.body = calloc( 1, o.body_size);
}
else if ( strcmp( element->Properties[0]->Value, "duration") == 0) {
o.cid = pwr_cClass_Opc_Duration;
o.body_size = sizeof(pwr_sClass_Opc_Duration);
o.body = calloc( 1, o.body_size);
}
else if ( strcmp( element->Properties[0]->Value, "QName") == 0) {
o.cid = pwr_cClass_Opc_QName;
o.body_size = sizeof(pwr_sClass_Opc_QName);
o.body = calloc( 1, o.body_size);
}
}
else {
o.cid = pwr_cClass_Opc_Hier;
}
}
if ( first)
m_list[fth].fchoix = o.oix;
else {
o.bwsoix = bws;
m_list[bws].fwsoix = o.oix;
}
if ( last) {
m_list[fth].lchoix = o.oix;
if ( !first) {
o.fwsoix = m_list[fth].fchoix;
m_list[o.fwsoix].bwsoix = o.oix;
}
else {
// Single child
o.fwsoix = o.oix;
o.bwsoix = o.oix;
}
}
if ( element->HasChildren && load_children)
o.flags |= procom_obj_mFlags_Loaded;
else if ( !element->HasChildren)
o.flags |= procom_obj_mFlags_Loaded;
m_list.push_back( o);
if ( load_children) {
_ns1__Browse browse;
_ns1__BrowseResponse browse_response;
if ( fth != 0)
browse.ItemPath = new std::string( longname(fth));
browse.ItemName = new std::string( o.name);
std::string s("dataType");
browse.PropertyNames.push_back( s);
if ( soap_call___ns1__Browse( &soap, opc_endpoint, NULL, &browse, &browse_response) ==
SOAP_OK) {
pwr_tOix next_bws;
pwr_tOix bws = 0;
for ( int i = 0; i < (int)browse_response.Elements.size(); i++) {
next_bws = next_oix;
insert_object( o.oix, bws, browse_response.Elements[i],
i == 0, i == (int)browse_response.Elements.size() - 1, 0);
bws = next_bws;
}
}
}
}
void opc_provider::objectOid( co_procom *pcom, pwr_tOix oix)
{
if ( m_list.size() == 0) {
// Insert volume object
procom_obj vo;
vo.cid = pwr_eClass_ExternVolume;
strcpy( vo.name, opc_vname);
vo.body_size = sizeof(pwr_sExternVolume);
vo.body = calloc( 1, vo.body_size);
vo.oix = 0;
vo.flags |= procom_obj_mFlags_Loaded;
m_list.push_back( vo);
// Load Rootlist
_ns1__Browse browse;
_ns1__BrowseResponse browse_response;
......@@ -63,32 +237,67 @@ void opc_provider::objectOid( co_procom *pcom, pwr_tOix oix)
browse.PropertyNames.push_back( s);
if ( soap_call___ns1__Browse( &soap, opc_endpoint, NULL, &browse, &browse_response) ==
SOAP_OK) {
pwr_tOix bws = 0;
pwr_tOix next_bws;
for ( int i = 0; i < (int)browse_response.Elements.size(); i++) {
procom_obj o;
strcpy( o.name, browse_response.Elements[i]->Name->c_str());
strcpy( o.lname, o.name);
o.oix = next_oix++;
if ( i != 0)
o.bwsoix = o.oix - 1;
if ( i != (int)browse_response.Elements.size() - 1)
o.fwsoix = o.oix + 1;
if ( browse_response.Elements[i]->HasChildren)
o.flags |= procom_obj_mFlags_Loaded;
else
o.flags |= procom_obj_mFlags_Loaded;
m_list.push_back( o);
next_bws = next_oix;
insert_object( oix, bws, browse_response.Elements[i],
i == 0, i == (int)browse_response.Elements.size() - 1, 1);
bws = next_bws;
}
}
else
soap_print_fault( &soap, stderr);
}
else if ( oix < m_list.size()) {
if ( !(m_list[oix].flags & procom_obj_mFlags_Loaded)) {
_ns1__Browse browse;
_ns1__BrowseResponse browse_response;
browse.ItemPath = new std::string( longname(m_list[oix].fthoix));
browse.ItemName = new std::string( m_list[oix].name);
std::string s("dataType");
browse.PropertyNames.push_back( s);
if ( soap_call___ns1__Browse( &soap, opc_endpoint, NULL, &browse, &browse_response) ==
SOAP_OK) {
pwr_tOix next_bws;
pwr_tOix bws = 0;
for ( int i = 0; i < (int)browse_response.Elements.size(); i++) {
next_bws = next_oix;
insert_object( oix, bws, browse_response.Elements[i],
i == 0, i == (int)browse_response.Elements.size() - 1, 0);
bws = next_bws;
}
}
m_list[oix].flags |= procom_obj_mFlags_Loaded;
}
}
if ( oix >= m_list.size() || oix < 0) {
pcom->provideStatus( GDH__NOSUCHOBJ);
return;
}
pcom->provideObjects( GDH__SUCCESS, m_list);
#if 0
for ( int i = 0; i < (int)m_list.size(); i++) {
printf( "oix %2d bws %2d fws %2d fth %2d fch %2d lch %2d flags %lu %s\n",
m_list[i].oix, m_list[i].bwsoix, m_list[i].fwsoix, m_list[i].fthoix,
m_list[i].fchoix, m_list[i].lchoix, m_list[i].flags, m_list[i].name);
}
#endif
vector<procom_obj>olist;
for ( int i = 0; i < (int) m_list.size(); i++) {
if ( m_list[i].flags & procom_obj_mFlags_Loaded)
olist.push_back( m_list[i]);
}
printf( "*********************************************\n");
for ( int i = 0; i < (int)olist.size(); i++) {
printf( "oix %2d bws %2d fws %2d fth %2d fch %2d lch %2d flags %lu %s\n",
olist[i].oix, olist[i].bwsoix, olist[i].fwsoix, olist[i].fthoix,
olist[i].fchoix, olist[i].lchoix, olist[i].flags, olist[i].name);
}
pcom->provideObjects( GDH__SUCCESS, olist);
}
void opc_provider::objectName( co_procom *pcom, char *name)
......@@ -271,7 +480,7 @@ int main(int argc, char *argv[])
/* Read arguments */
if ( argc < 4) {
usage();
strcpy( server_url, "http://localhost:18083");
strcpy( server_url, "http://linuxlab1:18083");
strcpy( extern_vid, "0.1.99.55");
strcpy( extern_volume_name, "MyOpcVolume");
// exit(0);
......
/*
* Proview $Id: opc_provider.h,v 1.1 2007-03-01 09:12:54 claes Exp $
* Proview $Id: opc_provider.h,v 1.2 2007-03-02 08:52:20 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -58,6 +58,9 @@ public:
virtual bool find( pwr_tOix fthoix, char *name, pwr_tOix *oix);
void insert_object( pwr_tOix fth, pwr_tOix bws, ns1__BrowseElement *element,
int first, int last, int load_children);
vector<procom_obj> m_list;
pwr_tOix root;
pwr_tOix next_oix;
......
/*
* Proview $Id: opc_server.cpp,v 1.1 2007-03-01 09:12:54 claes Exp $
* Proview $Id: opc_server.cpp,v 1.2 2007-03-02 08:52:20 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -25,6 +25,51 @@
#include "opc_soap_H.h"
#include "Service.nsmap"
static bool opc_type_to_string( int type, char **str)
{
*str = (char *) malloc(20);
switch ( type) {
case pwr_eType_String:
strcpy( *str, "string");
break;
case pwr_eType_Float32:
strcpy( *str, "float");
break;
case pwr_eType_Float64:
strcpy( *str, "double");
break;
case pwr_eType_Int32:
strcpy( *str, "int");
break;
case pwr_eType_Int16:
strcpy( *str, "short");
break;
case pwr_eType_Int8:
strcpy( *str, "char");
break;
case pwr_eType_UInt32:
strcpy( *str, "unsignedInt");
break;
case pwr_eType_UInt16:
strcpy( *str, "unsignedShort");
break;
case pwr_eType_UInt8:
strcpy( *str, "unsignedChar");
break;
case pwr_eType_Time:
strcpy( *str, "dateTime");
break;
case pwr_eType_DeltaTime:
strcpy( *str, "duration");
break;
default:
free( *str);
*str = 0;
return false;
}
return true;
}
int main()
{
......@@ -163,6 +208,8 @@ SOAP_FMAC5 int SOAP_FMAC6 __ns1__Browse(struct soap*, _ns1__Browse *ns1__Browse,
else {
// Return attributes and children
pwr_tOName itemname;
gdh_sAttrDef *bd;
int rows;
if ( ns1__Browse->ItemPath && !ns1__Browse->ItemPath->empty()) {
strncpy( itemname, ns1__Browse->ItemPath->c_str(), sizeof( itemname));
......@@ -179,6 +226,74 @@ SOAP_FMAC5 int SOAP_FMAC6 __ns1__Browse(struct soap*, _ns1__Browse *ns1__Browse,
return 0;
}
sts = gdh_GetObjectBodyDef( cid, &bd, &rows, oid);
if ( ODD(sts)) {
for ( int i = 0; i < rows; i++) {
if ( bd[i].flags & gdh_mAttrDef_Shadowed)
continue;
if ( bd[i].attr->Param.Info.Flags & PWR_MASK_RTVIRTUAL ||
bd[i].attr->Param.Info.Flags & PWR_MASK_PRIVATE)
continue;
if ( bd[i].attr->Param.Info.Type == pwr_eType_CastId ||
bd[i].attr->Param.Info.Type == pwr_eType_DisableAttr)
continue;
if ( bd[i].attr->Param.Info.Flags & PWR_MASK_RTHIDE)
continue;
if ( bd[i].attr->Param.Info.Flags & PWR_MASK_DISABLEATTR) {
pwr_sAttrRef aref = cdh_ObjidToAref( oid);
pwr_sAttrRef aaref;
pwr_tDisableAttr disabled;
sts = gdh_ArefANameToAref( &aref, bd[i].attrName, &aaref);
if ( EVEN(sts)) return sts;
sts = gdh_ArefDisabled( &aaref, &disabled);
if ( EVEN(sts)) return sts;
if ( disabled)
continue;
}
if ( bd[i].attr->Param.Info.Flags & PWR_MASK_ARRAY ) {
}
else if ( bd[i].attr->Param.Info.Flags & PWR_MASK_CLASS ) {
}
else {
ns1__BrowseElement *element = new ns1__BrowseElement();
element->Name = new std::string( bd[i].attrName);
element->ItemName = element->Name;
element->ItemPath = new std::string( itemname);
element->IsItem = true;
element->HasChildren = false;
for ( int i = 0; i < (int)ns1__Browse->PropertyNames.size(); i++) {
ns1__ItemProperty *property = new ns1__ItemProperty();
property->Name = ns1__Browse->PropertyNames[i];
if ( property->Name == "\"\":dataType") {
char *type_p;
if ( ! opc_type_to_string( bd[i].attr->Param.Info.Type, &type_p)) {
// Untranslatable type
element->IsItem = false;
element->HasChildren = false;
continue;
}
property->Value = type_p;
}
element->Properties.push_back( property);
}
ns1__BrowseResponse->Elements.push_back( element);
}
}
free( (char *)bd);
}
for ( sts = gdh_GetChild( oid, &child); ODD(sts); sts = gdh_GetNextSibling( child, &child)) {
sts = gdh_ObjidToName( child, name, sizeof(name), cdh_mName_object);
if ( EVEN(sts)) continue;
......
This diff is collapsed.
include $(pwre_dir_symbols)
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(hw_name)/$(type_name)_generic.mk
ifeq ($($(type_name)_generic_mk),)
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(type_name)_generic.mk
endif
ifeq ($($(type_name)_generic_mk),)
include $(pwre_kroot)/tools/bld/src/$(type_name)_generic.mk
endif
-include ../../special.mk
-include ../special.mk
-include special.mk
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