static const char *rcsId="@(#) $Id$";
static void *use_rcsId = (0 ? (void *)(&use_rcsId) : (void *) &rcsId);
#include <iostream>
using drama::thread::MonitorByType::MonitorByType;
void ParamChanged(
const std::string &name,
long value)
override;
void ParamChanged(
const std::string &name,
const std::string & value)
override;
};
void MyMonitor::ParamChanged(const std::string &name, long value)
{
std::cerr << "*** MyMonitor:ParamChanged (int) \""
<< name
<< "\" to \""
<< value
<< "\""
<< std::endl;
}
void MyMonitor::ParamChanged(
const std::string &name,
const std::string & value)
{
std::cerr << "*** MyMonitor:ParamChanged (string) \""
<< name
<< "\" to \""
<< value
<< "\""
<< std::endl;
}
void MyMonitor::ParamChanged(
const std::string &name,
{
std::cerr << "*** MyMonitor:ParamChanged (complex) \""
<< name
<< "\""
<< std::endl;
value->List(std::cerr);
}
{
try
{
testtask.GetPath(&ufaceHandler);
MyMonitor myMonitor(task->
TaskPtr(), {
"PARAM1" ,
"PARAM2",
"PARAM3",
"PARAM4" , "STRUCT_PARAM" });
try
{
ufaceHandler.MessageUser("About to run monitor");
myMonitor.Run(&testtask, &ufaceHandler);
}
{
throw e;
}
}
catch (...)
{
throw;
}
}
private:
public:
Monitor() :
drama::Task(
"MONITOR2") {
_ufaceThreadFuture = std::async(std::launch::async, MonitorThread, this);
}
if (_ufaceThreadFuture.wait_for(std::chrono::seconds(seconds)) !=
std::future_status::ready)
{
"UFACE Thread did not complete");
}
_ufaceThreadFuture.get();
}
~Monitor() {
}
};
int main()
{
try
{
Monitor task;
task.RunDrama();
task.WaitThreadExit(3);
}
{
}
catch (const std::exception &e)
{
std::cerr << "std::exception thrown by task.RunDrama"
<< e.what()
<< std::endl;
exit(1);
}
return 0;
}
virtual int statusAsSysExitCode() const
Return a system exit code based on the DRAMA Status.
Definition exception.hh:424
virtual void Print(FILE *file=stderr, bool include_stacktrace=false) const
Print exception details to a file.
virtual StatusType dramaStatus() const
Return the DRAMA Status code associated with the exception.
Definition exception.hh:404
An Exception class for exceptions thrown by DRAMA V2 classes.
Definition exception.hh:164
A Class which provides access to DRAMA's message sending facilities.
Definition path.hh:689
virtual void Add(const std::string &name, MessageHandlerPtr obj, const std::string &descr="")
Add an action to the task.
Definition task.hh:696
std::weak_ptr< Task > TaskPtr()
Returns a weak pointer to the task.
Definition task.hh:975
A class which implements a DRAMA task.
Definition task.hh:441
virtual void ParamChanged(const std::string &name, long value)
Method invoked when the value of a signed integer type parameter has been changed.
A class implementing Monitor which invokes particular methods for parameters of given base types.
Definition threadmonitor.hh:486
Constructing an object of this type will block all blockable UNIX signals in the current thread.
Definition thread.hh:586
A class which allows threads running in a User Interface or similar environments to send DRAMA messag...
Definition threaduface.hh:93
DRAMA 2 main include file.
#define DramaTHROW(status_, message_)
Throw a Drama exception.
Definition exception.hh:93
std::shared_ptr< Id > IdPtr
A shared pointer for sds::Id items.
Definition sds.hh:3318
void SignalDramaToExit(std::weak_ptr< Task > dramaTask, StatusType exitStatus=STATUS__OK)
Signal to DRAMA that this task should exit.
void CreateRunDramaTask()
Create and run a DRAMA task, with standard exception handling.
Definition task.hh:1322
Request SimpleExitAction(drama::MessageHandler *messageHandler)
A function which implements a simple exit action.
The drama namespace contains all the classes, types etc of the DRAMA 2 implementation.
Definition drama.hh:93
DRAMA 2 include file - Threaded monitoring classes.