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