本文整理汇总了C++中ITheFramework::AddConsumer方法的典型用法代码示例。如果您正苦于以下问题:C++ ITheFramework::AddConsumer方法的具体用法?C++ ITheFramework::AddConsumer怎么用?C++ ITheFramework::AddConsumer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITheFramework
的用法示例。
在下文中一共展示了ITheFramework::AddConsumer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ex_send_notifications
bool ex_send_notifications(void *arg)
{
ITheFramework *frame = Factory::GetFramework();
Decorator *decorator = ssi_create(Decorator, 0, true);
decorator->getOptions()->setOrigin(CONSOLE_WIDTH, 0);
frame->AddDecorator(decorator);
// start mouse
Mouse *mouse = ssi_create(Mouse, 0, true);
ITransformable *cursor_p = frame->AddProvider(mouse, SSI_MOUSE_CURSOR_PROVIDER_NAME);
frame->AddSensor(mouse);
// sender + receiver
NotifySender *sender = ssi_create_id(NotifySender, 0, "sender");
sender->setLogLevel(SSI_LOG_LEVEL_DEBUG);
sender->getOptions()->setUrl("udp://localhost:1111");
frame->AddRunnable(sender);
NotifyReceiver *receiver = ssi_create_id(NotifyReceiver, 0, "receiver");
receiver->setLogLevel(SSI_LOG_LEVEL_DEBUG);
receiver->getOptions()->setUrl("udp://localhost:1111");
receiver->getOptions()->setId("plot");
frame->AddRunnable((SSI_IRunnableObject*)receiver);
// control (place after sender!)
ControlCheckBox *checkbox = 0;
checkbox = ssi_create_id(ControlCheckBox, 0, "checkbox");
checkbox->getOptions()->setId("sender");
checkbox->getOptions()->setTitle("VISUALIZATION");
checkbox->getOptions()->setLabel("SHOW");
checkbox->getOptions()->value = false;
frame->AddRunnable(checkbox);
// plot
SignalPainter *plot;
plot = ssi_create_id(SignalPainter, 0, "plot");
plot->getOptions()->size = 10;
plot->getOptions()->setTitle("cursor");
frame->AddConsumer(cursor_p, plot, "0.2s");
decorator->add("plot*", 0, 0, 400, CONSOLE_HEIGHT - 200);
decorator->add("checkbox*", 0, CONSOLE_HEIGHT - 200, 400, 200);
frame->Start();
frame->Wait();
frame->Stop();
frame->Clear();
return true;
}
示例2: ex_sensor
bool ex_sensor(void *args)
{
ITheFramework *frame = Factory::GetFramework();
Decorator *decorator = ssi_create(Decorator, 0, true);
frame->AddDecorator(decorator);
PythonSensor *py_sensor = ssi_create(PythonSensor, 0, true);
py_sensor->getOptions()->setScript("ssi_sensor");
py_sensor->getOptions()->block = 0.5;
py_sensor->getOptions()->add("sr", "1000");
py_sensor->getOptions()->add("dim", "2");
ITransformable *sine_t = frame->AddProvider(py_sensor, "sine");
ITransformable *saw_t = frame->AddProvider(py_sensor, "saw");
frame->AddSensor(py_sensor);
SignalPainter *plot = 0;
plot = ssi_create_id(SignalPainter, 0, "plot");
plot->getOptions()->setTitle("SINE");
plot->getOptions()->size = 5;
frame->AddConsumer(sine_t, plot, "0.5s");
plot = ssi_create_id(SignalPainter, 0, "plot");
plot->getOptions()->setTitle("SAW");
plot->getOptions()->size = 5;
frame->AddConsumer(saw_t, plot, "0.5s");
decorator->add("console", 0, 0, 650, 800);
decorator->add("plot*", 650, 0, 400, 400);
decorator->add("monitor*", 650, 400, 400, 400);
frame->Start();
frame->Wait();
frame->Stop();
frame->Clear();
return true;
}
示例3: ex_stream_info
bool ex_stream_info(void *arg) {
Factory::RegisterDLL("ssimouse");
ITheFramework *frame = Factory::GetFramework();
Decorator *decorator = ssi_create (Decorator, 0, true);
frame->AddDecorator(decorator);
ITheEventBoard *board = Factory::GetEventBoard();
//ClockEventSender *eclock = ssi_create(ClockEventSender, 0, true);
Mouse *mouse = ssi_create(Mouse, "mouse", true);
mouse->getOptions()->mask = Mouse::LEFT;
mouse->getOptions()->scale = true;
mouse->getOptions()->single = false;
mouse->getOptions()->sendEvent = true;
ITransformable *cursor_p = frame->AddProvider(mouse, SSI_MOUSE_CURSOR_PROVIDER_NAME);
ITransformable *button_p = frame->AddProvider(mouse, SSI_MOUSE_BUTTON_PROVIDER_NAME);
frame->AddSensor(mouse);
board->RegisterSender(*mouse);
Websocket *websocket = ssi_create(Websocket, 0, true);
websocket->getOptions()->setHttpRoot("stream_to_browser_info");
websocket->getOptions()->send_info = true;
//frame->AddConsumer(cursor_p, websocket, "0.25s");
ssi::ITransformable *src[2] = { cursor_p, button_p };
frame->AddConsumer(2, src, websocket, "1");
board->RegisterSender(*websocket);
board->RegisterListener(*websocket);
EventMonitor *monitor = ssi_create_id (EventMonitor, 0, "monitor");
board->RegisterListener(*monitor);
decorator->add("console", 0, 0, 650, 800);
decorator->add("plot*", 650, 0, 400, 400);
decorator->add("monitor*", 650, 400, 400, 400);
board->Start();
frame->Start();
frame->Wait();
frame->Stop();
frame->Clear();
return true;
}
示例4: ex_pearson
bool ex_pearson(void *args)
{
ITheFramework *frame = Factory::GetFramework();
Decorator *decorator = ssi_create (Decorator, 0, true);
frame->AddDecorator(decorator);
Mouse *mouse = ssi_create(Mouse, 0, true);
ITransformable *cursor_t = frame->AddProvider(mouse, SSI_MOUSE_CURSOR_PROVIDER_NAME);
frame->AddSensor(mouse);
PythonFeature *ppmcc = ssi_create(PythonFeature, 0, true);
ppmcc->getOptions()->setScript("ssi_ppmcc");
ITransformable *ppmcc_t = frame->AddTransformer(cursor_t, ppmcc, "0.1s");
SignalPainter *plot = 0;
plot = ssi_create_id(SignalPainter, 0, "plot");
plot->getOptions()->setTitle("CURSOR");
plot->getOptions()->size = 5;
frame->AddConsumer(cursor_t, plot, "0.1s");
plot = ssi_create_id (SignalPainter, 0, "plot");
plot->getOptions()->setTitle("PPMCC");
plot->getOptions()->size = 5;
frame->AddConsumer(ppmcc_t, plot, "1");
decorator->add("console", 0, 0, 650, 800);
decorator->add("plot*", 650, 0, 400, 400);
decorator->add("monitor*", 650, 400, 400, 400);
frame->Start();
frame->Wait();
frame->Stop();
frame->Clear();
return true;
}
示例5: ex_imggray
bool ex_imggray(void *args)
{
ITheFramework *frame = Factory::GetFramework();
Decorator *decorator = ssi_create(Decorator, 0, true);
frame->AddDecorator(decorator);
FakeSignal *video = ssi_create(FakeSignal, 0, true);
video->getOptions()->type = FakeSignal::SIGNAL::IMAGE_RANDOM_RGB;
ITransformable *rgb_t = frame->AddProvider(video, "video");
frame->AddSensor(video);
PythonImageFilter *imggray = ssi_create(PythonImageFilter, 0, true);
imggray->getOptions()->setScript("ssi_imggray");
ITransformable *gray_t = frame->AddTransformer(rgb_t, imggray, "1");
VideoPainter *vidplot = 0;
vidplot = ssi_create_id(VideoPainter, 0, "plot");
vidplot->getOptions()->setTitle("RGB");
frame->AddConsumer(rgb_t, vidplot, "1");
vidplot = ssi_create_id(VideoPainter, 0, "plot");
vidplot->getOptions()->setTitle("GRAY");
frame->AddConsumer(gray_t, vidplot, "1");
decorator->add("console", 0, 0, 650, 800);
decorator->add("plot*", 650, 0, 400, 400);
decorator->add("monitor*", 650, 400, 400, 400);
frame->Start();
frame->Wait();
frame->Stop();
frame->Clear();
return true;
}
示例6: ex_event
bool ex_event(void *args)
{
ITheFramework *frame = Factory::GetFramework();
ITheEventBoard *board = Factory::GetEventBoard();
Decorator *decorator = ssi_create(Decorator, 0, true);
frame->AddDecorator(decorator);
Mouse *mouse = ssi_create(Mouse, 0, true);
mouse->getOptions()->mask = Mouse::LEFT;
ITransformable *button_t = frame->AddProvider(mouse, SSI_MOUSE_BUTTON_PROVIDER_NAME);
ITransformable *cursor_t = frame->AddProvider(mouse, SSI_MOUSE_CURSOR_PROVIDER_NAME);
frame->AddSensor(mouse);
PythonConsumer *py_send = ssi_create_id(PythonConsumer, 0, "pysend");
py_send->getOptions()->setScript("ssi_send");
ITransformable *input[] = { button_t, cursor_t };
frame->AddConsumer(2, input, py_send, "100ms");
board->RegisterSender(*py_send);
PythonObject *py_listen = ssi_create_id(PythonObject, 0, "pylisten");
py_listen->getOptions()->setScript("ssi_listen");
board->RegisterListener(*py_listen, py_send->getEventAddress());
EventMonitor *monitor = ssi_create_id(EventMonitor, 0, "monitor");
board->RegisterListener(*monitor, 0, 10000u);
SignalPainter *plot = 0;
plot = ssi_create_id(SignalPainter, 0, "plot");
plot->getOptions()->setTitle("CURSOR");
frame->AddEventConsumer(cursor_t, plot, board, py_send->getEventAddress());
decorator->add("console", 0, 0, 650, 800);
decorator->add("plot*", 650, 0, 400, 400);
decorator->add("monitor*", 650, 400, 400, 400);
board->Start();
frame->Start();
frame->Wait();
frame->Stop();
board->Stop();
frame->Clear();
board->Clear();
return true;
}
示例7: ex_trigger
bool ex_trigger (void *arg) {
ITheFramework *frame = Factory::GetFramework ();
//ssi_pcast(TheFramework, frame)->getOptions()->setConsolePos(800, 200, 400, 200);
Mouse *mouse = ssi_create (Mouse, 0, false);
mouse->getOptions ()->mask = Mouse::LEFT;
ITransformable *cursor_p = frame->AddProvider (mouse, SSI_MOUSE_CURSOR_PROVIDER_NAME);
ITransformable *button_p = frame->AddProvider (mouse, SSI_MOUSE_BUTTON_PROVIDER_NAME);
frame->AddSensor (mouse);
FileWriter *writer = ssi_create (FileWriter, 0, true);
writer->getOptions ()->type = File::ASCII;
frame->AddConsumer (cursor_p, writer, "0.2s", 0, 0, button_p);
frame->Start ();
frame->Wait ();
frame->Stop ();
frame->Clear ();
return true;
}
示例8: ex_sensor
bool ex_sensor (void *arg) {
ITheFramework *frame = Factory::GetFramework ();
//IThePainter *painter = Factory::GetPainter ();
//ITheEventBoard *board = Factory::GetEventBoard ();
Mouse *mouse = ssi_pcast (Mouse, Factory::Create (Mouse::GetCreateName (), "mouse"));
mouse->getOptions ()->mask = Mouse::LEFT;
ITransformable *cursor_p = frame->AddProvider (mouse, SSI_MOUSE_CURSOR_PROVIDER_NAME);
ITransformable *button_p = frame->AddProvider (mouse, SSI_MOUSE_BUTTON_PROVIDER_NAME);
frame->AddSensor (mouse);
ZeroEventSender *ezero = ssi_create (ZeroEventSender, "ezero", true);
ezero->getOptions ()->mindur = 0.2;
frame->AddConsumer (cursor_p, ezero, "0.25s");
/*
board->RegisterSender (*ezero);
SignalPainter *sigpaint = ssi_create (SignalPainter, 0, true);
sigpaint->getOptions ()->setName ("mouse");
sigpaint->getOptions ()->size = 2.0;
frame->AddConsumer (cursor_p, sigpaint, "0.2s");
sigpaint= ssi_create (SignalPainter, 0, true);
sigpaint->getOptions ()->setName ("mouse (tr)");
frame->AddEventConsumer (cursor_p, sigpaint, board, ezero->getEventAddress ());
*/
frame->Start ();
//board->Start ();
//painter->Arrange (2, 1, 0, 0, 800, 400);
frame->Wait ();
//board->Stop ();
frame->Stop ();
frame->Clear ();
//board->Clear ();
//painter->Clear ();
return true;
}
示例9: ex_simulator
bool ex_simulator(void *arg) {
if (!ssi_exists("cursor_txt.stream")) {
ex_writer(0);
}
ITheFramework *frame = Factory::GetFramework ();
Decorator *decorator = ssi_create (Decorator, 0, true);
frame->AddDecorator(decorator);
File::SetLogLevel (SSI_LOG_LEVEL_DEBUG);
FileReader *reader = ssi_create (FileReader, 0, true);
reader->getOptions()->setPath("cursor_txt");
reader->getOptions()->block = 0.05;
reader->getOptions()->loop = true;
reader->getOptions()->offset = 0.1;
ITransformable *cursor_p = frame->AddProvider(reader, SSI_FILEREADER_PROVIDER_NAME);
frame->AddSensor(reader);
FileWriter *writer = ssi_create (FileWriter, 0, true);
writer->getOptions()->type = File::ASCII;
frame->AddConsumer(cursor_p, writer, "0.05s");
decorator->add("console", 0, 0, 650, 800);
decorator->add("plot*", 650, 0, 400, 400);
decorator->add("monitor*", 650, 400, 400, 400);
frame->Start();
reader->wait();
frame->Stop();
frame->Clear();
return true;
}
示例10: ex_pitch
void ex_pitch () {
ITheFramework *frame = Factory::GetFramework ();
Decorator *decorator = ssi_create (Decorator, 0, true);
frame->AddDecorator(decorator);
// audio sensor
#ifndef SIMULATE
Audio *audio = ssi_create (Audio, "audio", true);
audio->getOptions()->scale = true;
ITransformable *audio_p = frame->AddProvider(audio, SSI_AUDIO_PROVIDER_NAME);
#else
WavReader *audio = ssi_create (WavReader, 0, true);
audio->getOptions()->setPath("audio.wav");
audio->getOptions()->scale = true;
ITransformable *audio_p = frame->AddProvider(audio, SSI_WAVREADER_PROVIDER_NAME);
#endif
frame->AddSensor(audio);
// fft
OSTransformFFT *fft = ssi_create (OSTransformFFT, "OSTransformFFT", true);
fft->getWindow()->getOptions()->type = OSWindow::GAUSS;
fft->getWindow()->getOptions()->gain = 1.0;
fft->getWindow()->getOptions()->sigma = 0.4;
double frameSize = audio_p->getSampleRate() * 0.01;
double deltaSize = audio_p->getSampleRate() * 0.04;
fft->getOptions()->nfft = smileMath_ceilToNextPowOf2(frameSize + deltaSize); //we set the FFT frame size so it's a power of 2 but can also fit all the samples
ITransformable *fft_t = frame->AddTransformer(audio_p, fft, "0.01s", "0.04s");
// fftmag
OSFFTmagphase *fftmag = ssi_create (OSFFTmagphase, "OSFFTmagphase", true);
ITransformable *fftmag_t = frame->AddTransformer(fft_t, fftmag, "0.1s");
// specscale
OSSpecScale *specscale = ssi_create (OSSpecScale, "OSSpecScale", true);
specscale->getOptions()->srcScale = OSSpecScale::LINEAR;
specscale->getOptions()->dstScale = OSSpecScale::LOG;
specscale->getOptions()->dstLogScaleBase = 2.0;
specscale->getOptions()->minF = 20;
specscale->getOptions()->smooth = true;
specscale->getOptions()->enhance = true;
specscale->getOptions()->weight = true;
specscale->getOptions()->fsSec = 0.064; // BUG?
ITransformable *specscale_t = frame->AddTransformer(fftmag_t, specscale, "0.1s");
// pitchshs
OSPitchShs *pitchshs = ssi_create (OSPitchShs, "OSPitchShs", false);
pitchshs->getOptions()->maxPitch = 620;
pitchshs->getOptions()->minPitch = 42;
pitchshs->getOptions()->nCandidates = 6;
pitchshs->getOptions()->scores = true;
pitchshs->getOptions()->voicing = true;
pitchshs->getOptions()->F0C1 = false;
pitchshs->getOptions()->voicingC1 = false;
pitchshs->getOptions()->F0raw = false;
pitchshs->getOptions()->voicingClip = false;
pitchshs->getOptions()->voicingCutoff = 0.7;
pitchshs->getOptions()->octaveCorrection = false;
pitchshs->getOptions()->fsSec = 0.064; // BUG?
pitchshs->getOptions()->baseSr = audio_p->getSampleRate();
ITransformable *pitchshs_t = frame->AddTransformer(specscale_t, pitchshs, "0.1s");
// pitchsmooth
OSPitchSmoother *pitchsmooth = ssi_create (OSPitchSmoother, "OSPitchSmoother", true);
pitchsmooth->getOptions()->medianFilter0 = 0;
pitchsmooth->getOptions()->postSmoothing = 0;
pitchsmooth->getOptions()->postSmoothingMethod = OSPitchSmoother::SIMPLE;
pitchsmooth->getOptions()->octaveCorrection = false;
pitchsmooth->getOptions()->F0final = true;
pitchsmooth->getOptions()->F0finalEnv = false;
pitchsmooth->getOptions()->voicingFinalClipped = false;
pitchsmooth->getOptions()->voicingFinalUnclipped = true;
pitchsmooth->getOptions()->F0raw = false;
pitchsmooth->getOptions()->voicingC1 = false;
pitchsmooth->getOptions()->voicingClip = false;
ITransformable *pitchsmooth_t = frame->AddTransformer(pitchshs_t, pitchsmooth, "0.1s");
// plot
SignalPainter *plot = 0;
plot = ssi_create_id (SignalPainter, 0, "plot");
plot->getOptions()->setTitle("audio");
plot->getOptions()->type = PaintSignalType::AUDIO;
plot->getOptions()->size = 10.0;
frame->AddConsumer(audio_p, plot, "0.1s");
plot = ssi_create_id (SignalPainter, 0, "plot");
plot->getOptions()->setTitle("fft");
plot->getOptions()->size = 10.0;
plot->getOptions()->type = PaintSignalType::IMAGE;
frame->AddConsumer(fft_t, plot, "0.1s");
plot = ssi_create_id (SignalPainter, 0, "plot");
plot->getOptions()->setTitle("fftmag");
plot->getOptions()->size = 10.0;
plot->getOptions()->type = PaintSignalType::IMAGE;
frame->AddConsumer(fftmag_t, plot, "0.1s");
plot = ssi_create_id (SignalPainter, 0, "plot");
//.........这里部分代码省略.........
示例11: ex_event
bool ex_event (void *arg) {
ITheFramework *frame = Factory::GetFramework ();
ssi_pcast(TheFramework, frame)->getOptions()->setConsolePos(800, 200, 400, 200);
//IThePainter *painter = Factory::GetPainter ();
//ITheEventBoard *board = Factory::GetEventBoard ();
Mouse *mouse = ssi_create (Mouse, 0, false);
mouse->getOptions ()->mask = Mouse::LEFT;
ITransformable *cursor_p = frame->AddProvider (mouse, SSI_MOUSE_CURSOR_PROVIDER_NAME);
ITransformable *button_p = frame->AddProvider (mouse, SSI_MOUSE_BUTTON_PROVIDER_NAME);
frame->AddSensor (mouse);
// output
/*
SignalPainter *signal_painter = 0;
signal_painter = ssi_create (SignalPainter, 0, true);
signal_painter->getOptions ()->size = 2.0;
signal_painter->getOptions ()->setName ("cursor");
frame->AddConsumer (cursor_p, signal_painter, "0.2s");
*/
// zero event
ZeroEventSender *ezero = ssi_create (ZeroEventSender, 0, true);
ezero->getOptions ()->setSender ("mouse");
ezero->getOptions ()->setEvent ("click");
ezero->getOptions ()->eager = true;
ezero->getOptions ()->eall = true;
ezero->getOptions ()->hard = true;
ezero->getOptions ()->mindur = 0.5;
ezero->getOptions ()->maxdur = 4.0;
ezero->getOptions ()->hangin = 5;
ezero->getOptions ()->hangout = 5;
ezero->getOptions ()->empty = false;
ezero->getOptions ()->setString("ezero");
frame->AddConsumer (button_p, ezero, "0.2s");
//board->RegisterSender (*ezero);
FloatsEventSender *fsender = ssi_factory_create (FloatsEventSender, 0, true);
fsender->getOptions ()->mean = true;
fsender->getOptions ()->setEventName ("position");
fsender->getOptions ()->setSenderName ("mouse");
//frame->AddEventConsumer (cursor_p, fsender, board, ezero->getEventAddress ());
//board->RegisterSender (*fsender);
/*
signal_painter = ssi_create (SignalPainter, 0, true);
signal_painter->getOptions ()->size = 0;
signal_painter->getOptions ()->setName ("click event");
frame->AddEventConsumer (cursor_p, signal_painter, board, ezero->getEventAddress ());
*/
// thres event
ThresEventSender *ethres = ssi_create (ThresEventSender, "ethres", true);
ethres->getOptions ()->setSender ("tes");
ethres->getOptions ()->setEvent ("te");
ethres->getOptions ()->hard = false;
ethres->getOptions ()->mindur = 0.5;
ethres->getOptions ()->maxdur = 4.0;
ethres->getOptions ()->hangin = 5;
ethres->getOptions ()->hangout = 5;
ethres->getOptions ()->thres = 0.5;
ethres->getOptions ()->empty = false;
ethres->getOptions ()->setString("ethres");
frame->AddConsumer (cursor_p, ethres, "0.2s");
//board->RegisterSender (*ethres);
EventConsumer *ethres_c = ssi_create (EventConsumer, 0, true);
ethres_c->getOptions ()->async = true;
//board->RegisterListener (*ethres_c, ethres->getEventAddress ());
/*
signal_painter = ssi_create (SignalPainter, 0, true);
signal_painter->getOptions ()->size = 0;
signal_painter->getOptions ()->setName ("thres event");
ethres_c->AddConsumer (cursor_p, signal_painter);
// event monitor
EventMonitor *emonitor = ssi_create (EventMonitor, 0, true);
emonitor->getOptions ()->setMonitorPos (0, 200, 800, 200);
board->RegisterListener (*emonitor, 0, 50000);
*/
// run
frame->Start ();
//board->Start ();
//painter->Arrange (3,1,0,0,800,200);
frame->Wait ();
//board->Stop ();
frame->Stop ();
frame->Clear ();
//board->Clear ();
//painter->Clear ();
return true;
}
示例12: ex_sender
bool ex_sender(void *arg) {
Socket::TYPE::List *type = ssi_pcast(Socket::TYPE::List, arg);
ITheFramework *frame = Factory::GetFramework();
Decorator *decorator = ssi_create(Decorator, 0, true);
decorator->getOptions()->setOrigin(CONSOLE_WIDTH, 0);
frame->AddDecorator(decorator);
// start mouse
Mouse *mouse = ssi_create (Mouse, "mouse", true);
ITransformable *cursor_p = frame->AddProvider(mouse, SSI_MOUSE_CURSOR_PROVIDER_NAME);
frame->AddSensor(mouse);
// start sender and receiver
SocketWriter *socket_writer_bin = ssi_create (SocketWriter, 0, true);
socket_writer_bin->getOptions()->setUrl(*type, "localhost", 1111);
socket_writer_bin->getOptions()->format = SocketWriter::Options::FORMAT::BINARY;
frame->AddConsumer(cursor_p, socket_writer_bin, "0.25s");
SocketReader *socket_reader_bin = ssi_create (SocketReader, 0, true);
socket_reader_bin->getOptions()->setUrl(*type, "localhost", 1111);
socket_reader_bin->getOptions()->format = SocketReader::Options::FORMAT::BINARY;
socket_reader_bin->getOptions()->setSampleInfo(cursor_p->getSampleRate(), cursor_p->getSampleDimension(), cursor_p->getSampleBytes(), cursor_p->getSampleType());
ITransformable *socket_reader_bin_p = frame->AddProvider(socket_reader_bin, SSI_SOCKETREADER_PROVIDER_NAME);
frame->AddSensor(socket_reader_bin);
SocketWriter *socket_writer_asc = ssi_create (SocketWriter, 0, true);
socket_writer_asc->getOptions()->setUrl(*type, "localhost", 2222);
socket_writer_asc->getOptions()->format = SocketWriter::Options::FORMAT::ASCII;
frame->AddConsumer(cursor_p, socket_writer_asc, "0.25s");
SocketReader *socket_reader_asc = ssi_create (SocketReader, 0, true);
socket_reader_asc->getOptions()->setUrl(*type, "localhost", 2222);
socket_reader_asc->getOptions()->format = SocketReader::Options::FORMAT::ASCII;
socket_reader_asc->getOptions()->setSampleInfo(cursor_p->getSampleRate(), cursor_p->getSampleDimension(), cursor_p->getSampleBytes(), cursor_p->getSampleType());
ITransformable *socket_reader_asc_p = frame->AddProvider(socket_reader_asc, SSI_SOCKETREADER_PROVIDER_NAME);
frame->AddSensor(socket_reader_asc);
SocketWriter *socket_writer_osc = ssi_create (SocketWriter, 0, true);
socket_writer_osc->getOptions()->setUrl(*type, "localhost", 3333);
socket_writer_osc->getOptions()->format = SocketWriter::Options::FORMAT::OSC;
socket_writer_osc->getOptions()->setId("mouse");
frame->AddConsumer(cursor_p, socket_writer_osc, "0.25s");
SocketReader *socket_reader_osc = ssi_create (SocketReader, 0, true);
socket_reader_osc->getOptions()->setUrl(*type, "localhost", 3333);
socket_reader_osc->getOptions()->format = SocketReader::Options::FORMAT::OSC;
socket_reader_osc->getOptions()->setSampleInfo(cursor_p->getSampleRate(), cursor_p->getSampleDimension(), cursor_p->getSampleBytes(), cursor_p->getSampleType());
ITransformable *socket_reader_osc_p = frame->AddProvider(socket_reader_osc, SSI_SOCKETREADER_PROVIDER_NAME);
frame->AddSensor(socket_reader_osc);
SignalPainter *plot;
plot =ssi_create_id(SignalPainter, 0, "plot");
plot->getOptions()->size = 10;
plot->getOptions()->setTitle("Local Sensor");
frame->AddConsumer(cursor_p, plot, "5");
plot =ssi_create_id(SignalPainter, 0, "plot");
plot->getOptions()->size = 10;
plot->getOptions()->setTitle("Socker Reader(Binary)");
frame->AddConsumer(socket_reader_bin_p, plot, "5");
plot =ssi_create_id(SignalPainter, 0, "plot");
plot->getOptions()->size = 10;
plot->getOptions()->setTitle("Socker Reader(ASCII)");
frame->AddConsumer(socket_reader_asc_p, plot, "5");
plot =ssi_create_id(SignalPainter, 0, "plot");
plot->getOptions()->size = 10;
plot->getOptions()->setTitle("Socker Reader(OSC)");
frame->AddConsumer(socket_reader_osc_p, plot, "5");
decorator->add("plot*", 0, 0, 400, CONSOLE_HEIGHT);
frame->Start();
frame->Wait();
frame->Stop();
frame->Clear();
return true;
}
示例13: ex_samples
bool ex_samples(void *arg) {
ITheFramework *frame = Factory::GetFramework();
Decorator *decorator = ssi_create (Decorator, 0, true);
frame->AddDecorator(decorator);
ITheEventBoard *board = Factory::GetEventBoard();
ssi_event_t e_class;
ssi_event_init(e_class, SSI_ETYPE_STRING, Factory::AddString("sender"), Factory::AddString("class"), 0, 0, SSI_MAX_CHAR);
Mouse *mouse = ssi_create(Mouse, 0, false);
mouse->getOptions()->mask = Mouse::LEFT;
ITransformable *cursor_p = frame->AddProvider(mouse, SSI_MOUSE_CURSOR_PROVIDER_NAME);
ITransformable *button_p = frame->AddProvider(mouse, SSI_MOUSE_BUTTON_PROVIDER_NAME);
frame->AddSensor(mouse);
FileSampleWriter *writer = 0;
writer = ssi_create(FileSampleWriter, 0, true);
writer->getOptions()->type = File::ASCII;
writer->getOptions()->setClasses("A;B");
writer->getOptions()->setUser("user");
frame->AddConsumer(cursor_p, writer, "1.0s");
board->RegisterListener(*writer, "[email protected]");
writer = ssi_create(FileSampleWriter, 0, true);
writer->getOptions()->setPath("test");
writer->getOptions()->type = File::BINARY;
writer->getOptions()->setClasses("A;B");
writer->getOptions()->setUser("user");
frame->AddConsumer(cursor_p, writer, "1.0s");
board->RegisterListener(*writer, "[email protected]");
writer = ssi_create(FileSampleWriter, 0, true);
writer->getOptions()->type = File::ASCII;
writer->getOptions()->setClasses("A;B");
writer->getOptions()->setUser("user");
writer->getOptions()->streamClassIndex = 1;
ITransformable *input[2] = { cursor_p, cursor_p };
frame->AddConsumer(2, input, writer, "1.0s");
decorator->add("console", 0, 0, 650, 800);
decorator->add("plot*", 650, 0, 400, 400);
decorator->add("monitor*", 650, 400, 400, 400);
board->Start();
frame->Start();
Sleep(2000);
ssi_strcpy(e_class.ptr, "B");
board->update(e_class);
Sleep(2000);
ssi_strcpy(e_class.ptr, "A");
board->update(e_class);
Sleep(2000);
ssi_strcpy(e_class.ptr, "");
board->update(e_class);
frame->Wait();
frame->Stop();
board->Stop();
frame->Clear();
board->Clear();
return true;
}
示例14: ex_annotation
bool ex_annotation(void *arg) {
ITheFramework *frame = Factory::GetFramework();
ITheEventBoard *board = Factory::GetEventBoard();
Mouse *mouse = ssi_create(Mouse, 0, true);
mouse->getOptions()->sr = 50.0;
mouse->getOptions()->mask = Mouse::LEFT;
ITransformable *cursor_p = frame->AddProvider(mouse, SSI_MOUSE_CURSOR_PROVIDER_NAME);
ITransformable *button_p = frame->AddProvider(mouse, SSI_MOUSE_BUTTON_PROVIDER_NAME);
frame->AddSensor(mouse);
TriggerEventSender *ezero = 0;
ezero = ssi_create(TriggerEventSender, 0, true);
ezero->getOptions()->triggerType = TriggerEventSender::TRIGGER::NOT_EQUAL;
ezero->getOptions()->setAddress("[email protected]");
ezero->getOptions()->minDuration = 0.2;
frame->AddConsumer(button_p, ezero, "0.25s");
board->RegisterSender(*ezero);
ezero = ssi_create(TriggerEventSender, 0, true);
ezero->getOptions()->triggerType = TriggerEventSender::TRIGGER::NOT_EQUAL;
ezero->getOptions()->setAddress("[email protected]");
ezero->getOptions()->minDuration = 0.2;
ezero->getOptions()->eventType = SSI_ETYPE_STRING;
ezero->getOptions()->setEventString("string");
frame->AddConsumer(button_p, ezero, "0.25s");
board->RegisterSender(*ezero);
StringEventSender *ssender = ssender = ssi_create(StringEventSender, 0, true);
ssender->getOptions()->setAddress("[email protected]");
ssender->getOptions()->mean = true;
frame->AddEventConsumer(cursor_p, ssender, board, ezero->getEventAddress());
board->RegisterSender(*ssender);
MapEventSender *msender = 0;
msender = ssi_create(MapEventSender, 0, true);
msender->getOptions()->setAddress("[email protected]");
msender->getOptions()->setKeys("x,y");
frame->AddEventConsumer(cursor_p, msender, board, ezero->getEventAddress());
board->RegisterSender(*msender);
msender = ssi_create(MapEventSender, 0, true);
msender->getOptions()->setAddress("[email protected]");
msender->getOptions()->setKeys("y,x");
frame->AddEventConsumer(cursor_p, msender, board, ezero->getEventAddress());
board->RegisterSender(*msender);
FileAnnotationWriter *annotation = 0;
annotation = ssi_create(FileAnnotationWriter, 0, true);
annotation->getOptions()->setAnnoPath("discrete_empty_and_string");
annotation->getOptions()->setSchemePath("scheme_discrete.annotation");
annotation->getOptions()->setDefaultLabel("empty");
annotation->getOptions()->defaultConfidence = 0.5f;
annotation->getOptions()->setMeta("annotator=hans;role=wurscht");
board->RegisterListener(*annotation, ezero->getEventAddress());
annotation = ssi_create(FileAnnotationWriter, 0, true);
annotation->getOptions()->setAnnoPath("discrete_map");
annotation->getOptions()->setSchemePath("scheme_discrete.annotation");
annotation->getOptions()->mapKeyIndex = 1;
annotation->getOptions()->setMeta("annotator=hans;role=wurscht");
board->RegisterListener(*annotation, msender->getEventAddress());
annotation = ssi_create(FileAnnotationWriter, 0, true);
annotation->getOptions()->setAnnoPath("free_empty_and_string");
annotation->getOptions()->setSchemePath("scheme_free");
annotation->getOptions()->setDefaultLabel("empty");
annotation->getOptions()->defaultConfidence = 0.5f;
annotation->getOptions()->setMeta("annotator=hans;role=wurscht");
board->RegisterListener(*annotation, ezero->getEventAddress());
annotation = ssi_create(FileAnnotationWriter, 0, true);
annotation->getOptions()->setAnnoPath("free_map");
annotation->getOptions()->setSchemePath("scheme_free");
annotation->getOptions()->mapKeyIndex = 1;
annotation->getOptions()->setMeta("annotator=hans;role=wurscht");
board->RegisterListener(*annotation, msender->getEventAddress());
annotation = ssi_create(FileAnnotationWriter, 0, true);
annotation->getOptions()->setAnnoPath("continuous");
annotation->getOptions()->setSchemePath("scheme_continuous");
annotation->getOptions()->setMeta("annotator=hans;role=wurscht");
frame->AddConsumer(cursor_p, annotation, "1.0s");
EventMonitor *monitor = ssi_create_id(EventMonitor, 0, "monitor");
monitor->getOptions()->setPos(CONSOLE_WIDTH, 0, 600, 300);
board->RegisterListener(*monitor, 0, 60000);
board->Start();
frame->Start();
frame->Wait();
frame->Stop();
board->Stop();
frame->Clear();
board->Clear();
//.........这里部分代码省略.........
示例15: ex_qrs_heartrate_mean
bool ex_qrs_heartrate_mean(void *args) {
if (!ssi_exists("data/ecg_qrs.stream")) {
ex_ecg_detection(args);
}
ITheFramework *frame = Factory::GetFramework();
Decorator *decorator = ssi_create(Decorator, 0, true);
frame->AddDecorator(decorator);
ITheEventBoard *board = Factory::GetEventBoard();
//raw
FileReader *reader = ssi_create(FileReader, 0, true);
reader->getOptions()->setPath("data/ecg_qrs");
reader->getOptions()->block = 0.2;
ITransformable *qrs_p = frame->AddProvider(reader, SSI_FILEREADER_PROVIDER_NAME);
frame->AddSensor(reader);
// heart rate
QRSHeartRate *qrshr = ssi_create(QRSHeartRate, 0, true);
ITransformable *ecg_hr_t = frame->AddTransformer(qrs_p, qrshr, "0.25s");
//heart rate mean
QRSHeartRateMean *qrshr_mean = ssi_create(QRSHeartRateMean, 0, true);
qrshr_mean->getOptions()->winsize = 15.0;
frame->AddConsumer(ecg_hr_t, qrshr_mean, "0.25s");
board->RegisterSender(*qrshr_mean);
//visual
SignalPainter *plot = 0;
ssi_real_t p_size = 100.0f;
//qrs
plot = ssi_create_id(SignalPainter, 0, "plot");
plot->getOptions()->setTitle("qrs");
plot->getOptions()->size = p_size;
frame->AddConsumer(qrs_p, plot, "0.3s");
//heart rate
plot = ssi_create_id(SignalPainter, 0, "plot");
plot->getOptions()->setTitle("heartrate");
plot->getOptions()->size = p_size;
frame->AddConsumer(ecg_hr_t, plot, "0.3s");
//events
EventMonitor *monitor = ssi_create_id(EventMonitor, 0, "monitor");
board->RegisterListener(*monitor, qrshr_mean->getEventAddress());
//framework
decorator->add("console", 0, 0, 650, 800);
decorator->add("plot*", 650, 0, 400, 400);
decorator->add("monitor*", 650, 400, 400, 400);
board->Start();
frame->Start();
frame->Wait();
frame->Stop();
board->Stop();
frame->Clear();
board->Clear();
return true;
}