From c714089784a471f0da47a5d5302808f3edee3a08 Mon Sep 17 00:00:00 2001 From: ronag Date: Fri, 11 Nov 2011 10:06:19 +0000 Subject: [PATCH] git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches/2.0 concrt-experimental@1555 362d55ac-95cf-4e76-9f9a-cbaa9c17b72d --- common/diagnostics/graph.cpp | 154 ++++++++++++----------- common/diagnostics/graph.h | 1 + modules/decklink/interop/DeckLinkAPI_h.h | 2 +- modules/decklink/interop/DeckLinkAPI_i.c | 2 +- protocol/amcp/AMCPCommandsImpl.cpp | 19 +++ protocol/amcp/AMCPCommandsImpl.h | 6 + protocol/amcp/AMCPProtocolStrategy.cpp | 1 + 7 files changed, 110 insertions(+), 75 deletions(-) diff --git a/common/diagnostics/graph.cpp b/common/diagnostics/graph.cpp index a7c3bc611..0b4348e0b 100644 --- a/common/diagnostics/graph.cpp +++ b/common/diagnostics/graph.cpp @@ -48,7 +48,7 @@ struct drawable : public sf::Drawable class context : public drawable { - sf::RenderWindow window_; + std::unique_ptr window_; std::list> drawables_; @@ -71,31 +71,51 @@ public: get_instance().do_register_drawable(drawable); }); } - + + static void show(bool value) + { + begin_invoke([=] + { + get_instance().do_show(value); + }); + } + private: context() : executor_(L"diagnostics") { - executor_.begin_invoke([this] - { - SetThreadPriority(GetCurrentThread(), BELOW_NORMAL_PRIORITY_CLASS); - window_.Create(sf::VideoMode(600, 1000), "CasparCG Diagnostics"); - window_.SetPosition(0, 0); - window_.SetActive(); - glEnable(GL_BLEND); - glEnable(GL_LINE_SMOOTH); - glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - tick(); - }); + } + + void do_show(bool value) + { + if(value) + { + if(!window_) + { + SetThreadPriority(GetCurrentThread(), BELOW_NORMAL_PRIORITY_CLASS); + window_.reset(new sf::RenderWindow(sf::VideoMode(600, 1000), "CasparCG Diagnostics")); + window_->SetPosition(0, 0); + window_->SetActive(); + glEnable(GL_BLEND); + glEnable(GL_LINE_SMOOTH); + glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + tick(); + } + } + else + window_.reset(); } void tick() { + if(!window_) + return; + sf::Event e; - while(window_.GetEvent(e)){} + while(window_->GetEvent(e)){} glClear(GL_COLOR_BUFFER_BIT); - window_.Draw(*this); - window_.Display(); + window_->Draw(*this); + window_->Display(); boost::this_thread::sleep(boost::posix_time::milliseconds(20)); executor_.begin_invoke([this]{tick();}); } @@ -112,8 +132,8 @@ private: auto& drawable = *it; if(!drawable.unique()) { - drawable->SetScale(static_cast(window_.GetWidth()), static_cast(target_dy*window_.GetHeight())); - float target_y = std::max(last_y, static_cast(n * window_.GetHeight())*target_dy); + drawable->SetScale(static_cast(window_->GetWidth()), static_cast(target_dy*window_->GetHeight())); + float target_y = std::max(last_y, static_cast(n * window_->GetHeight())*target_dy); drawable->SetPosition(0.0f, target_y); target.Draw(*drawable); ++it; @@ -169,12 +189,13 @@ class line : public drawable boost::optional guide_; boost::circular_buffer> line_data_; - std::vector tick_data_; - bool tick_tag_; + boost::circular_buffer tick_data_; + bool tick_tag_; color c_; public: line(size_t res = 600) : line_data_(res) + , tick_data_(50) , tick_tag_(false) , c_(1.0f, 1.0f, 1.0f) { @@ -349,21 +370,18 @@ private: implementation& operator=(implementation&); }; -graph::graph() : impl_(env::properties().get("configuration.diagnostics.graphs", true) ? new implementation("") : nullptr) +graph::graph() : impl_(new implementation("")) { } void graph::set_text(const std::string& value) { - if(impl_) + auto p = impl_; + context::begin_invoke([=] { - auto p = impl_; - context::begin_invoke([=] - { - p->set_text(value); - }); - } + p->set_text(value); + }); } void graph::set_text(const std::wstring& value) @@ -373,65 +391,55 @@ void graph::set_text(const std::wstring& value) void graph::update_value(const std::string& name, double value) { - if(impl_) + auto p = impl_; + context::begin_invoke([=] { - auto p = impl_; - context::begin_invoke([=] - { - p->update(name, value); - }); - } + p->update(name, value); + }); } void graph::set_value(const std::string& name, double value) -{ - if(impl_) - { - auto p = impl_; - context::begin_invoke([=] - { - p->set(name, value); - }); - } +{ + auto p = impl_; + context::begin_invoke([=] + { + p->set(name, value); + }); } void graph::set_color(const std::string& name, color c) -{ - if(impl_) - { - auto p = impl_; - context::begin_invoke([=] - { - p->set_color(name, c); - }); - } +{ + auto p = impl_; + context::begin_invoke([=] + { + p->set_color(name, c); + }); } void graph::add_tag(const std::string& name) -{ - if(impl_) - { - auto p = impl_; - context::begin_invoke([=] - { - p->tag(name); - }); - } +{ + auto p = impl_; + context::begin_invoke([=] + { + p->tag(name); + }); } void graph::add_guide(const std::string& name, double value) { - if(impl_) - { - auto p = impl_; - context::begin_invoke([=] - { - p->guide(name, value); - }); - } + auto p = impl_; + context::begin_invoke([=] + { + p->guide(name, value); + }); } void register_graph(const safe_ptr& graph) { - if(graph->impl_) - context::register_drawable(graph->impl_); + context::register_drawable(graph->impl_); +} + +void show_graphs(bool value) +{ + context::show(value); } + //namespace v2 //{ // diff --git a/common/diagnostics/graph.h b/common/diagnostics/graph.h index 59f8b46ba..268d74cb5 100644 --- a/common/diagnostics/graph.h +++ b/common/diagnostics/graph.h @@ -67,6 +67,7 @@ private: }; void register_graph(const safe_ptr& graph); +void show_graphs(bool value); //namespace v2 //{ diff --git a/modules/decklink/interop/DeckLinkAPI_h.h b/modules/decklink/interop/DeckLinkAPI_h.h index 59828dc95..ce47b7316 100644 --- a/modules/decklink/interop/DeckLinkAPI_h.h +++ b/modules/decklink/interop/DeckLinkAPI_h.h @@ -4,7 +4,7 @@ /* File created by MIDL compiler version 7.00.0555 */ -/* at Thu Oct 27 23:11:42 2011 +/* at Fri Nov 11 09:55:15 2011 */ /* Compiler settings for interop\DeckLinkAPI.idl: Oicf, W1, Zp8, env=Win32 (32b run), target_arch=X86 7.00.0555 diff --git a/modules/decklink/interop/DeckLinkAPI_i.c b/modules/decklink/interop/DeckLinkAPI_i.c index b4f30def5..6fe29b9eb 100644 --- a/modules/decklink/interop/DeckLinkAPI_i.c +++ b/modules/decklink/interop/DeckLinkAPI_i.c @@ -6,7 +6,7 @@ /* File created by MIDL compiler version 7.00.0555 */ -/* at Thu Oct 27 23:11:42 2011 +/* at Fri Nov 11 09:55:15 2011 */ /* Compiler settings for interop\DeckLinkAPI.idl: Oicf, W1, Zp8, env=Win32 (32b run), target_arch=X86 7.00.0555 diff --git a/protocol/amcp/AMCPCommandsImpl.cpp b/protocol/amcp/AMCPCommandsImpl.cpp index 44e907968..f9dc39f89 100644 --- a/protocol/amcp/AMCPCommandsImpl.cpp +++ b/protocol/amcp/AMCPCommandsImpl.cpp @@ -30,6 +30,7 @@ #include #include +#include #include #include @@ -195,6 +196,24 @@ void AMCPCommand::Clear() _parameters.clear(); } +bool DiagnosticsCommand::DoExecute() +{ + try + { + diagnostics::show_graphs(boost::lexical_cast(_parameters.at(0))); + + SetReplyString(TEXT("202 DIAG OK\r\n")); + + return true; + } + catch(...) + { + CASPAR_LOG_CURRENT_EXCEPTION(); + SetReplyString(TEXT("502 DIAG FAILED\r\n")); + return false; + } +} + bool ParamCommand::DoExecute() { //Perform loading of the clip diff --git a/protocol/amcp/AMCPCommandsImpl.h b/protocol/amcp/AMCPCommandsImpl.h index ef5f53bda..f027be46b 100644 --- a/protocol/amcp/AMCPCommandsImpl.h +++ b/protocol/amcp/AMCPCommandsImpl.h @@ -30,6 +30,12 @@ std::wstring ListTemplates(); namespace amcp { +class DiagnosticsCommand : public AMCPCommandBase +{ + std::wstring print() const { return L"DiagnosticsCommand";} + bool DoExecute(); +}; + class ParamCommand : public AMCPCommandBase { std::wstring print() const { return L"ParamCommand";} diff --git a/protocol/amcp/AMCPProtocolStrategy.cpp b/protocol/amcp/AMCPProtocolStrategy.cpp index 03b32196f..c545088d6 100644 --- a/protocol/amcp/AMCPProtocolStrategy.cpp +++ b/protocol/amcp/AMCPProtocolStrategy.cpp @@ -311,6 +311,7 @@ AMCPCommandPtr AMCPProtocolStrategy::CommandFactory(const std::wstring& str) transform(s.begin(), s.end(), s.begin(), toupper); if (s == TEXT("MIXER")) return std::make_shared(); + else if(s == TEXT("DIAG")) return std::make_shared(); else if(s == TEXT("PARAM")) return std::make_shared(); else if(s == TEXT("SWAP")) return std::make_shared(); else if(s == TEXT("LOAD")) return std::make_shared(); -- 2.39.5