2 * copyright (c) 2010 Sveriges Television AB <info@casparcg.com>
\r
4 * This file is part of CasparCG.
\r
6 * CasparCG is free software: you can redistribute it and/or modify
\r
7 * it under the terms of the GNU General Public License as published by
\r
8 * the Free Software Foundation, either version 3 of the License, or
\r
9 * (at your option) any later version.
\r
11 * CasparCG is distributed in the hope that it will be useful,
\r
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
14 * GNU General Public License for more details.
\r
16 * You should have received a copy of the GNU General Public License
\r
17 * along with CasparCG. If not, see <http://www.gnu.org/licenses/>.
\r
21 #include "..\stdafx.h"
\r
22 #include <algorithm>
\r
24 #include "CLKCommand.h"
\r
26 namespace caspar { namespace protocol { namespace CLK {
\r
28 CLKCommand::CLKCommand() : clockID_(0), command_(CLKInvalidCommand) {}
\r
30 CLKCommand::~CLKCommand() {}
\r
32 const std::wstring& CLKCommand::GetData()
\r
34 std::wstringstream dataStream;
\r
36 dataStream << TEXT("<templateData>");
\r
37 dataStream << TEXT("<componentData id=\"command\">");
\r
38 dataStream << TEXT("<command id=\"") << commandString_ << TEXT("\" time=\"") << time_ << TEXT("\" clockID=\"") << clockID_ << TEXT("\">");
\r
40 std::vector<std::wstring>::const_iterator it = parameters_.begin();
\r
41 std::vector<std::wstring>::const_iterator end = parameters_.end();
\r
42 for(; it != end; ++it) {
\r
43 dataStream << TEXT("<parameter>") << (*it) << TEXT("</parameter>");
\r
46 dataStream << TEXT("</command>");
\r
47 dataStream << TEXT("</componentData>");
\r
48 dataStream << TEXT("</templateData>");
\r
50 dataCache_ = dataStream.str();
\r
54 bool CLKCommand::SetCommand()
\r
56 bool bResult = true;
\r
57 std::transform(commandString_.begin(), commandString_.end(), commandString_.begin(), toupper);
\r
59 if(commandString_ == TEXT("DUR"))
\r
60 command_ = CLKDuration;
\r
61 else if(commandString_ == TEXT("NEWDUR"))
\r
62 command_ = CLKNewDuration;
\r
63 else if(commandString_ == TEXT("NEXTEVENT"))
\r
64 command_ = CLKNextEvent;
\r
65 else if(commandString_ == TEXT("STOP"))
\r
67 else if(commandString_ == TEXT("UNTIL"))
\r
68 command_ = CLKUntil;
\r
69 else if(commandString_ == TEXT("ADD"))
\r
71 else if(commandString_ == TEXT("SUB"))
\r
73 else if(commandString_ == TEXT("RESET"))
\r
74 command_ = CLKReset;
\r
77 command_ = CLKInvalidCommand;
\r
84 void CLKCommand::Clear()
\r
87 commandString_.clear();
\r
89 command_ = CLKDuration;
\r
91 parameters_.clear();
\r