Skip to content

Commit

Permalink
update to account for the store internal string format change
Browse files Browse the repository at this point in the history
  • Loading branch information
brichards64 committed Jun 8, 2024
1 parent 41dbdb8 commit f15723b
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 60 deletions.
8 changes: 4 additions & 4 deletions src/DAQDataModelBase/SlowControlCollection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ void SlowControlCollection::Thread(Thread_args* arg){
//tmp.Print();
//std::cout<<"str="<<str<<std::endl;

std::string reply="error: " + *tmp["msg_value"];
std::string reply="error: " + tmp.Get<std::string>("msg_value");

if(str == "?") reply=args->SCC->Print();
else if((*args->SCC)[str]){
Expand All @@ -187,9 +187,9 @@ void SlowControlCollection::Thread(Thread_args* arg){
reply=value;
}
else{
reply=*tmp["msg_value"];
tmp.Get("msg_value",reply);
std::stringstream input;
input<<*tmp["msg_value"];
input<<tmp.Get<std::string>("msg_value");
std::string key="";
std::string value="";
input>>key>>value;
Expand All @@ -205,7 +205,7 @@ void SlowControlCollection::Thread(Thread_args* arg){

Store rr;

*rr["msg_type"]="Command Reply";
rr.Set("msg_type", "Command Reply");
rr.Set("msg_value",reply);

std::string tmp2="";
Expand Down
12 changes: 6 additions & 6 deletions src/DAQDataModelBase/SlowControlElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ std::string SlowControlElement::Print(){
out+=m_name;

if(m_type==SlowControlElementType(VARIABLE)){
std::string min=*options["min"];
std::string max=*options["max"];
std::string step=*options["step"];
std::string value=*options["value"];
std::string min=options.Get<std::string>("min");
std::string max=options.Get<std::string>("max");
std::string step=options.Get<std::string>("step");
std::string value=options.Get<std::string>("value");


out+=":" + min + ":" + max + ":" + step + ":" + value + "]";
Expand All @@ -53,7 +53,7 @@ std::string SlowControlElement::Print(){
out+=";" + tmp;

}
std::string value=*options["value"];
std::string value=options.Get<std::string>("value");

out+= ";" + value + "]";
}
Expand All @@ -71,7 +71,7 @@ std::string SlowControlElement::Print(){
}

else if(m_type==SlowControlElementType(INFO)){
std::string value=*options["value"];
std::string value=options.Get<std::string>("value");
out+="{" + value + "}";
}

Expand Down
4 changes: 2 additions & 2 deletions src/DAQDataModelBase/SlowControlElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ namespace ToolFramework{
else if (value.at(i)=='"') value.at(i)='\'';
}
}
*(options["value"])= value;
options.Set("value", value);
mtx.unlock();
return true;
}
Expand All @@ -146,7 +146,7 @@ namespace ToolFramework{
mtx.unlock();
return false;
}
value=*(options["value"]);
options.Get("value", value);
mtx.unlock();
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions src/DAQLogging/DAQLogging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,8 @@ src/DAQLogging/DAQLogging.{h,cpp} -nw

outmessage.Set("uuid",UUID);
outmessage.Set("msg_id",msg_id);
*outmessage["msg_time"]=isot.str();
*outmessage["msg_type"]="Log";
outmessage.Set("msg_time", isot.str());
outmessage.Set("msg_type", "Log");
outmessage.Set("msg_value",ss.str());


Expand Down
33 changes: 17 additions & 16 deletions src/NodeDaemon/NodeDaemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,40 +148,41 @@ int main(int argc, char* argv[]){


std::string ret="Command not recognised (Use ? to find valid commands)";
std::string msg_value=bb.Get<std::string>("msg_value");

if(*(bb["msg_value"])=="KILL"){
if(msg_value=="KILL"){
ret="Killing NodeDaemon";
}

if(*(bb["msg_value"])=="Reboot"){
if(msg_value=="Reboot"){
ret="Rebooting Node";
}


if(*(bb["msg_value"])=="Status"){
if(msg_value=="Status"){
ret="Online";
}

else if (*(bb["msg_value"])=="?"){
else if (msg_value=="?"){
ret="Available commands: Status, Stop, FStop, (Start / Create) Restart, File name, Build, KILL, Reboot ";

}

else if (*(bb["msg_value"])=="FStop"){
else if (msg_value=="FStop"){
ret="Forcing ToolChain to Stop";
FStop(&pids);
}

else if (*(bb["msg_value"])=="Stop"){
else if (msg_value=="Stop"){
ret="Stopping ToolChains";
Stop(&pids);
}
else if(*(bb["msg_value"])=="Start" || *(bb["msg_value"])=="Create"){
else if(msg_value=="Start" || msg_value=="Create"){

ret=Start(&pids, *(bb["var1"]));
ret=Start(&pids, bb.Get<std::string>("var1"));
}

else if(*(bb["msg_value"])=="Restart"){
else if(msg_value=="Restart"){
ret="Restarting ToolChan";
Stop(&pids);
FStop(&pids);
Expand All @@ -190,9 +191,9 @@ int main(int argc, char* argv[]){
}


else if(*(bb["msg_value"])=="File"){
else if(msg_value=="File"){
ret="Receiving file";
std::ofstream outfile ((*(bb["var1"])).c_str());
std::ofstream outfile (bb.Get<std::string>("var1").c_str());
if (outfile.is_open()){

while (1) {
Expand Down Expand Up @@ -239,7 +240,7 @@ int main(int argc, char* argv[]){

}

else if (*(bb["msg_value"])=="Build"){
else if (msg_value=="Build"){
ret="Building ToolChain";
system("make clean; make");

Expand All @@ -258,8 +259,8 @@ int main(int argc, char* argv[]){

rr.Set("uuid",m_UUID);
rr.Set("msg_id",msg_id);
*rr["msg_time"]=isot.str();
*rr["msg_type"]="Command Reply";
rr.Set("msg_time", isot.str());
rr.Set("msg_type", "Command Reply");
rr.Set("msg_value",ret);


Expand All @@ -275,7 +276,7 @@ int main(int argc, char* argv[]){
if(out[0].revents & ZMQ_POLLOUT)direct.send(send);


if(*(bb["msg_value"])=="KILL"){
if(msg_value=="KILL"){

Stop(&pids);
FStop(&pids);
Expand All @@ -286,7 +287,7 @@ int main(int argc, char* argv[]){
//std::cout<<"got kill run set to false"<<std::endl;
}

if(*(bb["msg_value"])=="Reboot"){
if(msg_value=="Reboot"){
Stop(&pids);
FStop(&pids);
system("reboot --force");
Expand Down
32 changes: 16 additions & 16 deletions src/RemoteControl/RemoteControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ int main(int argc, char** argv){
std::istringstream ss(static_cast<char*>(servicem.data()));
service->JsonParser(ss.str());
std::string name;
name=*((*(service))["msg_value"]);
name=(*service).Get<std::string>("msg_value");

if(filter=="" || filter==name) RemoteServices.push_back(service);
else delete service;
Expand All @@ -123,10 +123,10 @@ int main(int argc, char** argv){
std::string time;

//*(it->second)>> output;
ip=*((*(RemoteServices.at(i)))["ip"]);
service=*((*(RemoteServices.at(i)))["msg_value"]);
status=*((*(RemoteServices.at(i)))["status"]);
time=*((*(RemoteServices.at(i)))["msg_time"]);
(*(RemoteServices.at(i))).Get("ip", ip);
(*(RemoteServices.at(i))).Get("msg_value", service);
(*(RemoteServices.at(i))).Get("status", status);
(*(RemoteServices.at(i))).Get("msg_time", time);

std::cout<<"["<<i<<"] "<<ip<<" , "<<service<<" , "<<status<<" , "<<time<<std::endl;

Expand Down Expand Up @@ -160,7 +160,7 @@ int main(int argc, char** argv){
ServiceSend.setsockopt(ZMQ_SNDTIMEO, a);

std::stringstream connection;
connection<<"tcp://"<<*((*(RemoteServices.at(ServiceNum)))["ip"])<<":"<<*((*(RemoteServices.at(ServiceNum)))["remote_port"]);
connection<<"tcp://"<<(*(RemoteServices.at(ServiceNum))).Get<std::string>("ip")<<":"<<(*(RemoteServices.at(ServiceNum))).Get<std::string>("remote_port");
ServiceSend.connect(connection.str().c_str());


Expand All @@ -173,8 +173,8 @@ int main(int argc, char** argv){

bb.Set("uuid",m_UUID);
bb.Set("msg_id",msg_id);
*bb["msg_time"]=isot.str();
*bb["msg_type"]="Command";
bb.Set("msg_time", isot.str());
bb.Set("msg_type", "Command");
bb.Set("msg_value",Send);
bb.Set("var1",var1);

Expand All @@ -192,7 +192,7 @@ int main(int argc, char** argv){
if(Send=="File"){

std::stringstream connection;
connection<<"tcp://"<<*((*(RemoteServices.at(ServiceNum)))["ip"])<<":"<<FILE_SEND_PORT;
connection<<"tcp://"<<(*(RemoteServices.at(ServiceNum))).Get<std::string>("ip")<<":"<<FILE_SEND_PORT;


zmq::socket_t ftp (context, ZMQ_PUSH);
Expand Down Expand Up @@ -243,7 +243,7 @@ int main(int argc, char** argv){

Store rr;
rr.JsonParser(answer);
if(*rr["msg_type"]=="Command Reply") std::cout<<std::endl<<*rr["msg_value"]<<std::endl<<std::endl;
if(rr.Get<std::string>("msg_type")=="Command Reply") std::cout<<std::endl<<(rr.Get<std::string>("msg_value"))<<std::endl<<std::endl;
}
else std::cout<<std::endl<<"message timed out"<<std::endl;

Expand Down Expand Up @@ -277,7 +277,7 @@ int main(int argc, char** argv){
for(unsigned int i=0; i<RemoteServices.size(); i++){

std::string service;
service=*((*(RemoteServices.at(i)))["msg_value"]);
(*(RemoteServices.at(i))).Get("msg_value", service);

if(service==ServiceName){

Expand All @@ -287,7 +287,7 @@ int main(int argc, char** argv){
ServiceSend.setsockopt(ZMQ_SNDTIMEO, a);

std::stringstream connection;
connection<<"tcp://"<<*((*(RemoteServices.at(i)))["ip"])<<":"<<*((*(RemoteServices.at(i)))["remote_port"]);
connection<<"tcp://"<<(*(RemoteServices.at(i))).Get<std::string>("ip")<<":"<<(*(RemoteServices.at(i))).Get<std::string>("remote_port");
ServiceSend.connect(connection.str().c_str());


Expand All @@ -300,8 +300,8 @@ int main(int argc, char** argv){

bb.Set("uuid",m_UUID);
bb.Set("msg_id",msg_id);
*bb["msg_time"]=isot.str();
*bb["msg_type"]="Command";
bb.Set("msg_time", isot.str());
bb.Set("msg_type", "Command");
bb.Set("msg_value",Send);
bb.Set("var1",var1);

Expand All @@ -319,7 +319,7 @@ int main(int argc, char** argv){
if(Send=="File"){

std::stringstream connection;
connection<<"tcp://"<<*((*(RemoteServices.at(i)))["ip"])<<":"<<FILE_SEND_PORT;
connection<<"tcp://"<<(*(RemoteServices.at(i))).Get<std::string>("ip")<<":"<<FILE_SEND_PORT;


zmq::socket_t ftp (context, ZMQ_PUSH);
Expand Down Expand Up @@ -370,7 +370,7 @@ int main(int argc, char** argv){

Store rr;
rr.JsonParser(answer);
if(*rr["msg_type"]=="Command Reply") std::cout<<std::endl<<*rr["msg_value"]<<std::endl<<std::endl;
if(rr.Get<std::string>("msg_type")=="Command Reply") std::cout<<std::endl<<rr.Get<std::string>("msg_value")<<std::endl<<std::endl;
}
}
}
Expand Down
20 changes: 10 additions & 10 deletions src/ServiceDiscovery/ServiceDiscovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,12 @@ void* ServiceDiscovery::MulticastPublishThread(void* arg){
std::vector<Store> PubServices;

Store bb;
*bb["msg_type"]="Service Discovery";
bb.Set("msg_type", "Service Discovery");
bb.Set("msg_value",m_service);
bb.Set("remote_port",m_remoteport);
if(m_remoteport) bb.Set("status_query",true);
else bb.Set("status_query",false);
bb.Set("uuid",m_UUID);
bb.Set("uuid",boost::uuids::to_string(m_UUID));
PubServices.push_back(bb);

// Initialize poll set
Expand Down Expand Up @@ -147,11 +147,11 @@ void* ServiceDiscovery::MulticastPublishThread(void* arg){
else if(command=="Add"){

Store bb;
*bb["msg_type"]="Service Discovery";
bb.Set("msg_type","Service Discovery");
bb.Set("msg_value",service);
bb.Set("remote_port",port);
bb.Set("status_query",statusquery);
bb.Set("uuid",uuid);
bb.Set("uuid",boost::uuids::to_string(uuid));
PubServices.push_back(bb);

}
Expand All @@ -160,7 +160,7 @@ void* ServiceDiscovery::MulticastPublishThread(void* arg){
for (it = PubServices.begin() ; it != PubServices.end(); ++it){
//std::cout<<"d3.5 "<<*((*it)["msg_value"])<<std::endl;

if(*((*it)["msg_value"])==service)break;
if((*it).Get<std::string>("msg_value")==service)break;


}
Expand Down Expand Up @@ -231,7 +231,7 @@ void* ServiceDiscovery::MulticastPublishThread(void* arg){
//StatusCheck.setsockopt(ZMQ_RCVTIMEO, a);
//StatusCheck.setsockopt(ZMQ_SNDTIMEO, a);
std::stringstream connection;
connection<<"tcp://localhost:"<<*(PubServices.at(i)["remote_port"]);
connection<<"tcp://localhost:"<<PubServices.at(i).Get<std::string>("remote_port");
// StatusCheck.setsockopt(ZMQ_IMMEDIATE, 1);
StatusCheck.setsockopt (ZMQ_LINGER, &linger, sizeof (linger));

Expand Down Expand Up @@ -338,12 +338,12 @@ void* ServiceDiscovery::MulticastPublishThread(void* arg){

// PubServices.at(i).Set("uuid",m_UUID);
PubServices.at(i).Set("msg_id",msg_id);
*(PubServices.at(i))["msg_time"]=isot.str();
PubServices.at(i).Set("msg_time", isot.str());
// *bb["msg_type"]="Service Discovery";
// bb.Set("msg_value",m_service);
//bb.Set("remote_port",m_remoteport);
if(statusquery) *(PubServices.at(i))["status"]=*mm["msg_value"];
else *(PubServices.at(i))["status"]= "N/A";
if(statusquery) PubServices.at(i).Set("status",mm.Get<std::string>("msg_value"));
else PubServices.at(i).Set("status","N/A");
std::string pubmessage;
PubServices.at(i)>>pubmessage;

Expand Down Expand Up @@ -490,7 +490,7 @@ void* ServiceDiscovery::MulticastListenThread(void* arg){
std::string uuid;
newservice->Get("uuid",uuid);
if(RemoteServices.count(uuid)) delete RemoteServices[uuid];

//std::cout<<uuid<<std::endl;
RemoteServices[uuid]=newservice;


Expand Down
8 changes: 4 additions & 4 deletions src/ToolDAQChain/ToolDAQChain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ void ToolDAQChain::Remote(){

Store rr;
rr.JsonParser(command);
if(*rr["msg_type"]=="Command") command=*rr["msg_value"];
if(rr.Get<std::string>("msg_type")=="Command") command=rr.Get<std::string>("msg_value");
else command="NULL";


Expand All @@ -225,10 +225,10 @@ void ToolDAQChain::Remote(){
msg_id++;
Store bb;

bb.Set("uuid",m_UUID);
bb.Set("uuid",boost::uuids::to_string(m_UUID));
bb.Set("msg_id",msg_id);
*bb["msg_time"]=isot.str();
*bb["msg_type"]="Command Reply";
bb.Set("msg_time", isot.str());
bb.Set("msg_type", "Command Reply");
bb.Set("msg_value",ExecuteCommand(command));


Expand Down

0 comments on commit f15723b

Please sign in to comment.