Commit 8a36f763 authored by claes's avatar claes

*** empty log message ***

parent 4d57af1b
/*
* Proview $Id: opc_provider.cpp,v 1.9 2007-03-27 08:37:50 claes Exp $
* Proview $Id: opc_provider.cpp,v 1.10 2007-04-05 13:32:03 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -583,10 +583,42 @@ void opc_provider::objectOid( co_procom *pcom, pwr_tOix oix)
}
#endif
vector<procom_obj>olist;
if ( oix == 0)
olist.push_back( m_list[0]->po);
else {
int plist_cnt = 0;
pwr_tOix p, c;
pwr_tOix plist[100];
// Get parents
for ( p = m_list[oix]->po.fthoix;
;
p = m_list[p]->po.fthoix) {
plist[plist_cnt++] = p;
if ( m_list[p]->po.fthoix == 0)
break;
}
// Add parents
for ( int i = plist_cnt - 1; i >= 0; i--)
olist.push_back( m_list[plist[i]]->po);
// Add siblings
for ( c = m_list[plist[0]]->po.fchoix; ; c = m_list[c]->po.fwsoix) {
if ( m_list[c]->po.flags & procom_obj_mFlags_Loaded)
olist.push_back( m_list[c]->po);
if ( m_list[c]->po.fwsoix == m_list[plist[0]]->po.fchoix)
break;
}
}
#if 0
for ( int i = 0; i < (int) m_list.size(); i++) {
if ( m_list[i]->po.flags & procom_obj_mFlags_Loaded)
olist.push_back( m_list[i]->po);
}
#endif
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",
......@@ -598,33 +630,85 @@ void opc_provider::objectOid( co_procom *pcom, pwr_tOix oix)
void opc_provider::objectName( co_procom *pcom, char *name, pwr_tOix poix)
{
pwr_tOName oname;
pwr_tStatus sts = GDH__SUCCESS;
cdh_sParseName pn;
pwr_tOix oix, coix;
if ( poix) {
if ( poix >= m_list.size()) {
pcom->provideStatus( GDH__NOSUCHOBJ);
return;
}
strcpy( oname, longname(poix));
strcat( oname, "-");
strcat( oname, name);
}
cdh_ParseName( &sts, &pn, pwr_cNOid, name, 0);
if ( poix)
oix = poix;
else
strcpy( oname, name);
oix = 0;
for ( int i = 0; i < (int) m_list.size(); i++) {
if ( !m_list[i]->po.flags & procom_obj_mFlags_Deleted) {
if ( cdh_NoCaseStrcmp( oname, longname(m_list[i]->po.oix)) == 0) {
objectOid( pcom, i);
return;
for ( int i = 0; i < (int)pn.nObject; i++) {
bool found = false;
if ( !(m_list[oix]->po.flags & procom_obj_mFlags_Loaded)) {
_s0__Browse browse;
_s0__BrowseResponse browse_response;
browse.ItemName = new std::string( m_list[oix]->item_name);
opc_mask_to_propertynames( browse.PropertyNames,
opc_mProperty_DataType | opc_mProperty_Description |
opc_mProperty_EuType);
if ( soap_call___s0__Browse( &soap, opc_endpoint, NULL, &browse, &browse_response) ==
SOAP_OK) {
pwr_tOix next_bws;
pwr_tOix bws = 0;
server_state->RequestCnt++;
if ( browse_response.Errors.size() > 0) {
errlog( browse.ItemName, browse_response.Errors);
}
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, 0);
bws = next_bws;
}
m_list[oix]->po.flags |= procom_obj_mFlags_Loaded;
}
else {
// Error returned from soap
server_state->RequestCnt++;
fault();
sts = GDH__NOSUCHOBJ;
break;
}
}
for ( coix = m_list[oix]->po.fchoix; ;
coix = m_list[coix]->po.fwsoix) {
if ( cdh_NoCaseStrcmp( m_list[coix]->po.name, pn.object[i].name.norm) == 0) {
oix = coix;
found = true;
break;
}
if ( m_list[coix]->po.fwsoix == m_list[oix]->po.fchoix)
// Last child
break;
}
if ( !found)
sts = GDH__NOSUCHOBJ;
}
if ( m_env == pvd_eEnv_Wb)
pcom->provideObject( 0,0,0,0,0,0,0,0,"","");
else
pcom->provideStatus( GDH__NOSUCHOBJ);
if ( ODD(sts)) {
objectOid( pcom, oix);
}
else {
if ( m_env == pvd_eEnv_Wb)
pcom->provideObject( 0,0,0,0,0,0,0,0,"","");
else
pcom->provideStatus( sts);
}
}
// Wb only
......@@ -908,6 +992,7 @@ void opc_provider::subDisassociateBuffer( co_procom *pcom, pwr_tSubid sid)
void opc_provider::cyclic( co_procom *pcom)
{
int size = 0;
bool reconnect = false;
_s0__SubscriptionPolledRefresh subpoll;
_s0__SubscriptionPolledRefreshResponse subpoll_response;
......@@ -928,23 +1013,110 @@ void opc_provider::cyclic( co_procom *pcom)
int idx = 0;
for ( sublist_iterator it = m_sublist.begin(); it != m_sublist.end(); it++) {
if ( subpoll_response.RItemList[idx]->Items.size()) {
opc_convert_opctype_to_pwrtype( (void *) ((pwr_sClass_Opc_String *)m_list[it->second.oix]->po.body)->Value,
m_list[it->second.oix]->size,
subpoll_response.RItemList[idx]->Items[0]->Value,
(pwr_eType) m_list[it->second.oix]->type);
#if 0
switch ( m_list[it->second.oix]->po.cid) {
case pwr_cClass_Opc_String:
strcpy( ((pwr_sClass_Opc_String *)m_list[it->second.oix]->po.body)->Value,
((xsd__string *)subpoll_response.RItemList[idx]->Items[0]->Value)->__item.c_str());
break;
default: ;
if ( subpoll_response.RItemList[idx]->Items[0]->ResultID) {
int code;
if ( opc_string_to_resultcode( (char *)subpoll_response.RItemList[idx]->Items[0]->ResultID->c_str(),
&code)) {
if ( code == opc_eResultCode_E_NOSUBSCRIPTION) {
// Subscription removed, add new subscription
reconnect = true;
break;
}
else {
server_state->LastError = code;
server_state->ErrorRequestCnt = server_state->RequestCnt;
}
}
}
else {
pwr_tOix oix = it->second.oix;
opc_convert_opctype_to_pwrtype( (void *) ((pwr_sClass_Opc_String *)m_list[oix]->po.body)->Value,
m_list[oix]->size,
subpoll_response.RItemList[idx]->Items[0]->Value,
(pwr_eType) m_list[oix]->type);
}
#endif
}
idx++;
}
if ( reconnect) {
int idx = 0;
map<pwr_tUInt32, opcprv_sub> sublist_add;
map<pwr_tUInt32, opcprv_sub> sublist_erase;
for ( sublist_iterator it = m_sublist.begin(); it != m_sublist.end(); it++) {
if ( subpoll_response.RItemList[idx]->Items.size()) {
if ( subpoll_response.RItemList[idx]->Items[0]->ResultID) {
int code;
if ( opc_string_to_resultcode( (char *)subpoll_response.RItemList[idx]->Items[0]->ResultID->c_str(),
&code)) {
if ( code == opc_eResultCode_E_NOSUBSCRIPTION) {
// Subscription removed, add new subscription
server_state->LastError = code;
server_state->ErrorRequestCnt = server_state->RequestCnt;
_s0__Subscribe subscribe;
_s0__SubscribeResponse subscribe_response;
pwr_tOix oix = it->second.oix;
pwr_tUInt32 rix = it->first;
subscribe.Options = new s0__RequestOptions();
subscribe.Options->ReturnItemTime = (bool *) malloc( sizeof(bool));
*subscribe.Options->ReturnItemTime = true;
subscribe.ItemList = new s0__SubscribeRequestItemList();
s0__SubscribeRequestItem *ritem = new s0__SubscribeRequestItem();
ritem->ItemName = new std::string( m_list[oix]->item_name);
ritem->ClientItemHandle = new std::string( it->second.handle);
ritem->RequestedSamplingRate = (int *) malloc( sizeof(int));
*ritem->RequestedSamplingRate = 1000;
subscribe.ItemList->Items.push_back( ritem);
// Remove old subscription
//m_sublist.erase( it);
sublist_erase[it->first] = it->second;
printf( "Reconnect: %s\n", m_list[oix]->item_name);
if ( soap_call___s0__Subscribe( &soap, opc_endpoint, NULL, &subscribe, &subscribe_response) ==
SOAP_OK) {
opcprv_sub sub;
// Insert new subscription with new handle
sub.handle = *subscribe_response.ServerSubHandle;
sub.oix = oix;
//m_sublist[rix] = sub;
sublist_add[rix] = sub;
server_state->RequestCnt++;
if ( subscribe_response.RItemList && subscribe_response.RItemList->Items.size()) {
for ( int i = 0; i < (int)subscribe_response.RItemList->Items.size(); i++) {
// subscribe_response.RItemList->Items[i]->ItemValue...
}
}
}
else {
// Error returned from soap
server_state->RequestCnt++;
fault();
}
}
}
}
}
}
idx++;
// Remove old subscriptions to m_sublist
for ( sublist_iterator it = sublist_erase.begin(); it != sublist_erase.end(); it++) {
m_sublist.erase(it->first);
}
// Add new subscriptions to m_sublist
for ( sublist_iterator it = sublist_add.begin(); it != sublist_add.end(); it++) {
m_sublist[it->first] = it->second;
}
}
}
else {
// Error returned from soap
......@@ -1025,8 +1197,8 @@ void opc_provider::get_server_state()
strcpy( server_state->VendorInfo, get_status_response.Status->VendorInfo->c_str());
if ( get_status_response.Status->ProductVersion)
strcpy( server_state->ProductVersion, get_status_response.Status->ProductVersion->c_str());
opc_convert_opctype_to_pwrtype( &server_state->StartTime, sizeof(server_state->StartTime),
&get_status_response.Status->StartTime, pwr_eType_Time);
opc_time_OPCAsciiToA( (char *)get_status_response.Status->StartTime.c_str(),
&server_state->StartTime);
server_state->ServerState = get_status_response.GetStatusResult->ServerState;
}
else {
......
This diff is collapsed.
......@@ -418,9 +418,9 @@ class s0__browseFilter_ : public xsd__anyType
class s0__ReplyBase : public xsd__anyType
{ public:
/// Attribute RcvTime of type xs:dateTime.
@xsd__dateTime RcvTime 1; ///< Required attribute.
@std::string RcvTime 1; ///< Required attribute.
/// Attribute ReplyTime of type xs:dateTime.
@xsd__dateTime ReplyTime 1; ///< Required attribute.
@std::string ReplyTime 1; ///< Required attribute.
/// Attribute ClientRequestHandle of type xs:string.
@std::string* ClientRequestHandle 0; ///< Optional attribute.
/// Attribute RevisedLocaleID of type xs:string.
......@@ -441,7 +441,7 @@ class s0__ServerStatus : public xsd__anyType
/// Vector of enum s0__interfaceVersion with length 0..unbounded
std::vector<enum s0__interfaceVersion> SupportedInterfaceVersions 0;
/// Attribute StartTime of type xs:dateTime.
@xsd__dateTime StartTime 1; ///< Required attribute.
@std::string StartTime 1; ///< Required attribute.
/// Attribute ProductVersion of type xs:string.
@std::string* ProductVersion 0; ///< Optional attribute.
};
......@@ -460,7 +460,7 @@ class s0__RequestOptions : public xsd__anyType
/// Attribute ReturnItemName of type xs:boolean.
@bool* ReturnItemName 0; ///< Optional attribute.
/// Attribute RequestDeadline of type xs:dateTime.
@xsd__dateTime* RequestDeadline 0; ///< Optional attribute.
@std::string* RequestDeadline 0; ///< Optional attribute.
/// Attribute ClientRequestHandle of type xs:string.
@std::string* ClientRequestHandle 0; ///< Optional attribute.
/// Attribute LocaleID of type xs:string.
......@@ -522,7 +522,7 @@ class s0__ItemValue : public xsd__anyType
/// Attribute ClientItemHandle of type xs:string.
@std::string* ClientItemHandle 0; ///< Optional attribute.
/// Attribute Timestamp of type xs:dateTime.
@xsd__dateTime* Timestamp 0; ///< Optional attribute.
@std::string* Timestamp 0; ///< Optional attribute.
/// Attribute ResultID of type xs:QName.
@xsd__QName* ResultID 0; ///< Optional attribute.
};
......@@ -918,7 +918,7 @@ class _s0__SubscriptionPolledRefresh
/// Vector of std::string with length 0..unbounded
std::vector<std::string > ServerSubHandles 0;
/// Attribute HoldTime of type xs:dateTime.
@xsd__dateTime* HoldTime 0; ///< Optional attribute.
@std::string* HoldTime 0; ///< Optional attribute.
/// Attribute WaitTime of type xs:int.
@int* WaitTime 0; ///< Optional attribute.
/// Attribute ReturnAllItems of type xs:boolean.
......
This diff is collapsed.
......@@ -6,7 +6,7 @@
*/
#include "opc_soap_H.h"
SOAP_SOURCE_STAMP("@(#) opc_soap_Client.cpp ver 2.7.9d 2007-03-23 08:02:36 GMT")
SOAP_SOURCE_STAMP("@(#) opc_soap_Client.cpp ver 2.7.9d 2007-03-30 08:43:57 GMT")
SOAP_FMAC5 int SOAP_FMAC6 soap_call___s0__GetStatus(struct soap *soap, const char *soap_endpoint, const char *soap_action, _s0__GetStatus *s0__GetStatus, _s0__GetStatusResponse *s0__GetStatusResponse)
......
This diff is collapsed.
......@@ -6,7 +6,7 @@
*/
#include "opc_soap_H.h"
SOAP_SOURCE_STAMP("@(#) opc_soap_Server.cpp ver 2.7.9d 2007-03-23 08:02:36 GMT")
SOAP_SOURCE_STAMP("@(#) opc_soap_Server.cpp ver 2.7.9d 2007-03-30 08:43:57 GMT")
SOAP_FMAC5 int SOAP_FMAC6 soap_serve(struct soap *soap)
......
......@@ -503,12 +503,12 @@ public:
#ifndef SOAP_TYPE_s0__ReplyBase
#define SOAP_TYPE_s0__ReplyBase (38)
/* s0:ReplyBase */
/* Primitive s0:ReplyBase schema type: */
class SOAP_CMAC s0__ReplyBase : public xsd__anyType
{
public:
xsd__dateTime RcvTime; /* required element of type xsd:dateTime */
xsd__dateTime ReplyTime; /* required element of type xsd:dateTime */
std::string RcvTime; /* required attribute */
std::string ReplyTime; /* required attribute */
std::string *ClientRequestHandle; /* optional attribute */
std::string *RevisedLocaleID; /* optional attribute */
enum s0__serverState ServerState; /* required attribute */
......@@ -535,7 +535,7 @@ public:
std::string *VendorInfo; /* optional element of type xsd:string */
std::vector<std::string >SupportedLocaleIDs; /* optional element of type xsd:string */
std::vector<enum s0__interfaceVersion >SupportedInterfaceVersions; /* optional element of type s0:interfaceVersion */
xsd__dateTime StartTime; /* required element of type xsd:dateTime */
std::string StartTime; /* required attribute */
std::string *ProductVersion; /* optional attribute */
public:
virtual int soap_type() const { return 39; } /* = unique id SOAP_TYPE_s0__ServerStatus */
......@@ -552,7 +552,7 @@ public:
#ifndef SOAP_TYPE_s0__RequestOptions
#define SOAP_TYPE_s0__RequestOptions (40)
/* s0:RequestOptions */
/* Primitive s0:RequestOptions schema type: */
class SOAP_CMAC s0__RequestOptions : public xsd__anyType
{
public:
......@@ -561,7 +561,7 @@ public:
bool *ReturnItemTime; /* optional attribute */
bool *ReturnItemPath; /* optional attribute */
bool *ReturnItemName; /* optional attribute */
xsd__dateTime *RequestDeadline; /* optional element of type xsd:dateTime */
std::string *RequestDeadline; /* optional attribute */
std::string *ClientRequestHandle; /* optional attribute */
std::string *LocaleID; /* optional attribute */
public:
......@@ -658,7 +658,7 @@ public:
std::string *ItemPath; /* optional attribute */
std::string *ItemName; /* optional attribute */
std::string *ClientItemHandle; /* optional attribute */
xsd__dateTime *Timestamp; /* optional element of type xsd:dateTime */
std::string *Timestamp; /* optional attribute */
std::string *ResultID; /* optional attribute */
public:
virtual int soap_type() const { return 44; } /* = unique id SOAP_TYPE_s0__ItemValue */
......@@ -1436,7 +1436,7 @@ class SOAP_CMAC _s0__SubscriptionPolledRefresh
public:
s0__RequestOptions *Options; /* optional element of type s0:RequestOptions */
std::vector<std::string >ServerSubHandles; /* optional element of type xsd:string */
xsd__dateTime *HoldTime; /* optional element of type xsd:dateTime */
std::string *HoldTime; /* optional attribute */
int *WaitTime; /* optional attribute */
bool *ReturnAllItems; /* optional attribute */
struct soap *soap; /* transient */
......@@ -1631,7 +1631,7 @@ public:
#endif
#ifndef SOAP_TYPE___s0__GetStatus
#define SOAP_TYPE___s0__GetStatus (156)
#define SOAP_TYPE___s0__GetStatus (155)
/* Operation wrapper: */
struct __s0__GetStatus
{
......@@ -1641,7 +1641,7 @@ public:
#endif
#ifndef SOAP_TYPE___s0__Read
#define SOAP_TYPE___s0__Read (160)
#define SOAP_TYPE___s0__Read (159)
/* Operation wrapper: */
struct __s0__Read
{
......@@ -1651,7 +1651,7 @@ public:
#endif
#ifndef SOAP_TYPE___s0__Write
#define SOAP_TYPE___s0__Write (164)
#define SOAP_TYPE___s0__Write (163)
/* Operation wrapper: */
struct __s0__Write
{
......@@ -1661,7 +1661,7 @@ public:
#endif
#ifndef SOAP_TYPE___s0__Subscribe
#define SOAP_TYPE___s0__Subscribe (168)
#define SOAP_TYPE___s0__Subscribe (167)
/* Operation wrapper: */
struct __s0__Subscribe
{
......@@ -1671,7 +1671,7 @@ public:
#endif
#ifndef SOAP_TYPE___s0__SubscriptionPolledRefresh
#define SOAP_TYPE___s0__SubscriptionPolledRefresh (172)
#define SOAP_TYPE___s0__SubscriptionPolledRefresh (171)
/* Operation wrapper: */
struct __s0__SubscriptionPolledRefresh
{
......@@ -1681,7 +1681,7 @@ public:
#endif
#ifndef SOAP_TYPE___s0__SubscriptionCancel
#define SOAP_TYPE___s0__SubscriptionCancel (176)
#define SOAP_TYPE___s0__SubscriptionCancel (175)
/* Operation wrapper: */
struct __s0__SubscriptionCancel
{
......@@ -1691,7 +1691,7 @@ public:
#endif
#ifndef SOAP_TYPE___s0__Browse
#define SOAP_TYPE___s0__Browse (180)
#define SOAP_TYPE___s0__Browse (179)
/* Operation wrapper: */
struct __s0__Browse
{
......@@ -1701,7 +1701,7 @@ public:
#endif
#ifndef SOAP_TYPE___s0__GetProperties
#define SOAP_TYPE___s0__GetProperties (184)
#define SOAP_TYPE___s0__GetProperties (183)
/* Operation wrapper: */
struct __s0__GetProperties
{
......@@ -1711,7 +1711,7 @@ public:
#endif
#ifndef SOAP_TYPE_SOAP_ENV__Header
#define SOAP_TYPE_SOAP_ENV__Header (187)
#define SOAP_TYPE_SOAP_ENV__Header (186)
/* SOAP Header: */
struct SOAP_ENV__Header
{
......@@ -1721,7 +1721,7 @@ public:
#endif
#ifndef SOAP_TYPE_SOAP_ENV__Code
#define SOAP_TYPE_SOAP_ENV__Code (188)
#define SOAP_TYPE_SOAP_ENV__Code (187)
/* SOAP Fault Code: */
struct SOAP_ENV__Code
{
......@@ -1732,7 +1732,7 @@ public:
#endif
#ifndef SOAP_TYPE_SOAP_ENV__Detail
#define SOAP_TYPE_SOAP_ENV__Detail (190)
#define SOAP_TYPE_SOAP_ENV__Detail (189)
/* SOAP-ENV:Detail */
struct SOAP_ENV__Detail
{
......@@ -1744,7 +1744,7 @@ public:
#endif
#ifndef SOAP_TYPE_SOAP_ENV__Reason
#define SOAP_TYPE_SOAP_ENV__Reason (191)
#define SOAP_TYPE_SOAP_ENV__Reason (190)
/* SOAP-ENV:Reason */
struct SOAP_ENV__Reason
{
......@@ -1754,7 +1754,7 @@ public:
#endif
#ifndef SOAP_TYPE_SOAP_ENV__Fault
#define SOAP_TYPE_SOAP_ENV__Fault (192)
#define SOAP_TYPE_SOAP_ENV__Fault (191)
/* SOAP Fault: */
struct SOAP_ENV__Fault
{
......
/*
* Proview $Id: opc_utl.cpp,v 1.15 2007-03-23 08:19:45 claes Exp $
* Proview $Id: opc_utl.cpp,v 1.16 2007-04-05 13:32:03 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -18,6 +18,7 @@
*/
#include <float.h>
#include "pwr_class.h"
#include "co_time.h"
#include "co_time_msg.h"
......@@ -65,29 +66,30 @@ static char opc_PropertyNames[17][20] = {"dataType",
"openLabel",
"timeZone"};
static char opc_ResultCodes[23][32] = {"s:S_CLAMP",
"s:S_DATAQUEUEOVERFLOW",
"s:S_UNSUPPORTEDRATE",
"s:E_ACCESS_DENIED",
"s:E_BUSY",
"s:E_FAIL",
"s:E_INVALIDCONTINUATIONPOINT",
"s:E_INVALIDFILTER",
"s:E_INVALIDHOLDTIME",
"s:E_INVALIDITEMNAME",
"s:E_INVALIDITEMPATH",
"s:E_INVALIDPID",
"s:E_NOSUBSCRIPTION",
"s:E_NOTSUPPORTED",
"s:E_OUTOFMEMORY",
"s:E_RANGE",
"s:E_READONLY",
"s:E_SERVERSTATE",
"s:E_TIMEDOUT",
"s:E_UNKNOWNITEMNAME",
"s:E_UNKNOWNITEMPATH",
"s:E_WRITEONLY",
"s:E_BADTYPE"};
static char opc_ResultCodes[24][32] = {"",
"s0:S_CLAMP",
"s0:S_DATAQUEUEOVERFLOW",
"s0:S_UNSUPPORTEDRATE",
"s0:E_ACCESS_DENIED",
"s0:E_BUSY",
"s0:E_FAIL",
"s0:E_INVALIDCONTINUATIONPOINT",
"s0:E_INVALIDFILTER",
"s0:E_INVALIDHOLDTIME",
"s0:E_INVALIDITEMNAME",
"s0:E_INVALIDITEMPATH",
"s0:E_INVALIDPID",
"s0:E_NOSUBSCRIPTION",
"s0:E_NOTSUPPORTED",
"s0:E_OUTOFMEMORY",
"s0:E_RANGE",
"s0:E_READONLY",
"s0:E_SERVERSTATE",
"s0:E_TIMEDOUT",
"s0:E_UNKNOWNITEMNAME",
"s0:E_UNKNOWNITEMPATH",
"s0:E_WRITEONLY",
"s0:E_BADTYPE"};
static char opc_ResultTexts[23][140] = {
"The value written was accepted but the output was clamped.",
......@@ -245,6 +247,7 @@ pwr_tStatus time_AtoOPCAscii (pwr_tTime *tp, char *buf, int bufsize)
int buflen;
char tmpStr[16];
pwr_tTime t;
int tzone;
if ( !tp) {
clock_gettime( CLOCK_REALTIME, &t);
......@@ -252,9 +255,10 @@ pwr_tStatus time_AtoOPCAscii (pwr_tTime *tp, char *buf, int bufsize)
}
tmpTm = localtime(&tp->tv_sec);
tzone = tmpTm->tm_gmtoff / 3600;
strftime(buf, bufsize, "%Y-%m-%dT%H:%M:%S", tmpTm);
sprintf(tmpStr, ".%07d", (int)(tp->tv_nsec / 100));
sprintf(tmpStr, ".%07d%s%02d:00", (int)(tp->tv_nsec / 100), tzone >= 0 ? "+" : "", tzone);
buflen = strlen(buf);
if (strlen(tmpStr) + buflen < (unsigned int) bufsize)
strcpy(&buf[buflen], tmpStr);
......@@ -963,7 +967,7 @@ bool opc_convert_opctype_to_pwrtype(void *bufp, int size, xsd__anyType *value, p
bool opc_convert_pwrtype_to_opctype(void *bufin, void *bufout, int size, int opc_type, int pwr_type)
{
if ( !bufout)
bufin = bufout;
bufout = bufin;
switch (opc_type) {
case opc_eDataType_string:
switch (pwr_type) {
......@@ -1633,7 +1637,7 @@ bool opc_get_property( std::vector<s0__ItemProperty *> properties, unsigned int
bool opc_propertynames_to_mask( std::vector<std::string>& pnames, unsigned int *mask)
{
char name[40];
char name[200];
char *np;
*mask = 0;
......@@ -1646,6 +1650,9 @@ bool opc_propertynames_to_mask( std::vector<std::string>& pnames, unsigned int *
np = name;
switch ( *np) {
case 'a':
*mask |= opc_mProperty_AccessRights;
break;
case 'd':
switch ( *(np+1)) {
case 'a':
......@@ -1789,3 +1796,26 @@ bool opc_quality_to_string( int quality, char **str)
return true;
}
bool opc_cmp_pwr( void *p1, void *p2, int size, int type, float deadband)
{
switch ( type) {
case pwr_eType_Boolean:
case pwr_eType_Int32:
case pwr_eType_UInt32:
if ( *(pwr_tUInt32 *)p1 == *(pwr_tUInt32 *)p2)
return true;
break;
case pwr_eType_Float32:
if ( deadband == 0) {
if ( fabs( *(pwr_tFloat32 *)p1 - *(pwr_tFloat32 *)p2) < FLT_EPSILON)
return true;
}
else {
if ( fabs( *(pwr_tFloat32 *)p1 - *(pwr_tFloat32 *)p2) < deadband)
return true;
}
break;
default: ;
}
return false;
}
/*
* Proview $Id: opc_utl.h,v 1.14 2007-03-27 08:37:50 claes Exp $
* Proview $Id: opc_utl.h,v 1.15 2007-04-05 13:32:03 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -131,3 +131,5 @@ void opc_mask_to_propertynames( std::vector<std::string>& pnames, unsigned int m
bool opc_propertynames_to_mask( std::vector<std::string>& pnames, unsigned int *mask);
bool opc_quality_to_string( int quality, char **str);
bool opc_cmp_pwr( void *p1, void *p2, int size, int type, float deadband);
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