cwIo,cwUi : Added realTimeReport()

This commit is contained in:
kevin 2023-12-03 11:18:02 -05:00
parent e24b5b43b2
commit c0cf1ca956
4 changed files with 35 additions and 10 deletions

View File

@ -3734,3 +3734,11 @@ void cw::io::uiReport( handle_t h )
if(_handleToUiHandle(h,uiH) == kOkRC )
ui::report(uiH);
}
void cw::io::uiRealTimeReport( handle_t h )
{
ui::handle_t uiH;
if(_handleToUiHandle(h,uiH) == kOkRC )
ui::realTimeReport(uiH);
}

1
cwIo.h
View File

@ -398,6 +398,7 @@ namespace cw
rc_t uiSendValue( handle_t h, unsigned uuId, double value );
rc_t uiSendValue( handle_t h, unsigned uuId, const char* value );
void uiRealTimeReport( handle_t h );
void uiReport( handle_t h );
}

View File

@ -96,8 +96,7 @@ namespace cw
unsigned* sessA; // sessA[ sessN ] array of wsSessId's
unsigned sessN;
unsigned sessAllocN;
bool msgCacheEnableFl;
unsigned msgCacheSessId;
char* msgCache;
@ -106,6 +105,9 @@ namespace cw
unsigned msgCacheN;
unsigned msgCacheMsgN;
unsigned sentMsgN;
unsigned recvMsgN;
} ui_t;
ui_t* _handleToPtr( handle_t h )
@ -326,6 +328,14 @@ namespace cw
return nullptr;
}
rc_t _send_callback( ui_t* p, unsigned wsSessId, const void* msg, unsigned msgByteN )
{
p->sentMsgN += 1;
rc_t rc = p->sendCbFunc( p->sendCbArg, wsSessId, msg, msgByteN );
return rc;
}
rc_t _cache_flush( ui_t* p )
{
@ -338,7 +348,7 @@ namespace cw
p->msgCache[ p->msgCacheN+1 ] = '}';
p->msgCache[ p->msgCacheN+2 ] = 0;
rc = p->sendCbFunc( p->sendCbArg, p->msgCacheSessId, p->msgCache, strlen(p->msgCache) );
rc = _send_callback(p, p->msgCacheSessId, p->msgCache, strlen(p->msgCache) );
p->msgCacheN = snprintf(p->msgCache,p->msgCacheAllocN,"{\"op\":\"cache\", \"array\": [");
p->msgCacheSessId = kInvalidId;
@ -369,7 +379,7 @@ namespace cw
rc = _cache_flush(p);
if( msgByteN > p->msgCacheDataN )
rc = p->sendCbFunc( p->sendCbArg, wsSessId, msg, msgByteN );
rc = _send_callback(p, wsSessId, msg, msgByteN );
else
{
assert( p->msgCacheN + msgByteCommaN <= p->msgCacheDataN );
@ -396,7 +406,7 @@ namespace cw
if( p->msgCacheEnableFl )
rc = _cache_send( p, sessId, msg, msgByteCnt );
else
rc = p->sendCbFunc( p->sendCbArg, sessId, msg, msgByteCnt );
rc = _send_callback(p, sessId, msg, msgByteCnt );
return rc;
}
@ -1295,6 +1305,7 @@ cw::rc_t cw::ui::create(
if((rc = _createFromObj( p, main_obj, kInvalidId, kRootUuId, kInvalidId )) != kOkRC )
rc = cwLogError(rc,"Create from UI resource failed.");
}
h.set(p);
@ -1454,6 +1465,8 @@ cw::rc_t cw::ui::onReceive( handle_t h, unsigned wsSessId, const void* void_msg,
while( (msg = _get_msg_from_recv_buffer(p)) != NULL )
{
p->recvMsgN += 1;
// parse the 'opId' from the message
opId = _labelToOpId(msg);
@ -2110,12 +2123,15 @@ void cw::ui::report( handle_t h )
e->attr->child_ele(i)->to_string(p->buf,p->bufN);
printf("%s, ", p->buf );
}
printf("\n");
}
printf("\n");
}
}
void cw::ui::realTimeReport( handle_t h )
{
ui_t* p = _handleToPtr(h);
printf("UI msg count: recv:%i send:%i\n",p->recvMsgN,p->sentMsgN);
}
namespace cw

2
cwUi.h
View File

@ -171,7 +171,7 @@ namespace cw
void report( handle_t h );
void realTimeReport( handle_t h );
namespace ws