- tms-old
- tms
- libTms
- TmsEventServerList.cc
This file ( 3kB ) exceeds the allowed full mode (48 kb) size.
The editor full hight is disabled, only scrolling is allowed..
If you wish to edit a file, it is recommended to use the scroll mode as some users do not like the full height
mode, although some users like it.
/*******************************************************************************
* TmsEventServerList.cc TMS List of Event Servers
* T.Barnaby, BEAM Ltd, 2007-04-19
*******************************************************************************
*/
#include <stdlib.h>
#include <stdint.h>
#include <TmsEventServerList.h>
namespace Tms {
TmsEventServerList::TmsEventServerList(){
}
TmsEventServerList::~TmsEventServerList(){
olock.lock();
olock.unlock();
}
BError TmsEventServerList::append(BString name){
BError err;
TmsEvent* e = new TmsEvent(name);
#ifdef ZAP
if(err = e->connectService(name)){
delete e;
printf("TmsEventServerList::append: Connection Error: %s\n", err.getString().retStr());
return err;
}
#endif
// printf("TmsEventServerList::append: Name: %s Num: %d\n", name.retStr(), oeventServers.number());
del(name); // Make sure there is only one entry
olock.lock();
oeventServers.append(e);
olock.unlock();
return err;
}
BError TmsEventServerList::del(BString name){
BError err;
BIter i;
olock.lock();
for(oeventServers.start(i); !oeventServers.isEnd(i); ){
if(oeventServers[i]->getServiceName() == name){
delete oeventServers[i];
oeventServers.del(i);
}
else {
oeventServers.next(i);
}
}
olock.unlock();
return err;
}
BError TmsEventServerList::errorEvent(BUInt32 cycleNumber, BError error){
BError err;
BIter i;
olock.lock();
for(oeventServers.start(i); !oeventServers.isEnd(i); ){
if(err = oeventServers[i]->errorEvent(cycleNumber, error)){
if(err.getErrorNo() < 0){
delete oeventServers[i];
oeventServers.del(i);
}
else {
oeventServers.next(i);
}
}
else {
oeventServers.next(i);
}
}
olock.unlock();
return err;
}
BError TmsEventServerList::cycleStartEvent(BUInt32 cycleNumber){
BError err;
BIter i;
olock.lock();
// printf("TmsEventServerList::cycleStartEvent: Num: %d\n", oeventServers.number());
for(oeventServers.start(i); !oeventServers.isEnd(i); ){
if(err = oeventServers[i]->cycleStartEvent(cycleNumber)){
if(err.getErrorNo() < 0){
delete oeventServers[i];
oeventServers.del(i);
}
else {
oeventServers.next(i);
}
}
else {
oeventServers.next(i);
}
}
olock.unlock();
return err;
}
BError TmsEventServerList::cycleStopEvent(BUInt32 cycleNumber){
BError err;
BIter i;
olock.lock();
for(oeventServers.start(i); !oeventServers.isEnd(i); ){
if(err = oeventServers[i]->cycleStopEvent(cycleNumber)){
if(err.getErrorNo() < 0){
delete oeventServers[i];
oeventServers.del(i);
}
else {
oeventServers.next(i);
}
}
else {
oeventServers.next(i);
}
}
olock.unlock();
return err;
}
BError TmsEventServerList::dataEvent(DataInfo dataInfo){
BError err;
BIter i;
olock.lock();
for(oeventServers.start(i); !oeventServers.isEnd(i); ){
if(err = oeventServers[i]->dataEvent(dataInfo)){
if(err.getErrorNo() < 0){
delete oeventServers[i];
oeventServers.del(i);
}
else {
oeventServers.next(i);
}
}
else {
oeventServers.next(i);
}
}
olock.unlock();
return err;
}
}