Avionics
Dropship Simulator
RTU.cpp
Go to the documentation of this file.
1 #include "Module.h"
2 
3 Rtu::Rtu(Bus* prmBus, Logger* prmLogger) : Module(prmBus)
4 {
5  logger = prmLogger;
6 }
7 
8 void Rtu::FrameMove(float fElapsedTime)
9 {
10  for (UINT i = 0; i < bus->commandStream.size(); i++)
11  {
12  Command command = bus->commandStream.at(i);
13  if (command.delay != 0.0f) continue;
14 
15  if (command.name == "PushToTalkDepress")
16  {
17  UINT location = static_cast<UINT>(command.ivalue);
18  if (location + 1 > bus->Transmitting.size())
19  {
20  logger->Log("Rtu::FrameMove DCU BUS transmitting location failure", Logger::Error);
21  break;
22  }
23 
25  if (!bus->Transmitting.at(location))
26  {
27  bus->Transmitting.at(location) = true;
28 
29  Command newCommand;
30  newCommand.name = "RtuTransmit";
31  newCommand.bvalue = true;
32  bus->commandStream.push_back(newCommand);
33  }
34  bus->commandStream.erase(bus->commandStream.begin() + i);
35  }
36  else if (command.name == "PushToTalkRelease")
37  {
38  UINT location = static_cast<UINT>(command.ivalue);
39  if (location + 1 > bus->Transmitting.size())
40  {
41  logger->Log("Rtu::FrameMove DCU BUS transmitting location failure", Logger::Error);
42  break;
43  }
44 
45  if (bus->Transmitting.at(location)) // only release if it was me
46  {
47  bus->Transmitting.at(location) = false;
48 
49  Command newCommand;
50  newCommand.name = "RtuTransmit";
51  newCommand.bvalue = false;
52  bus->commandStream.push_back(newCommand);
53  }
54  bus->commandStream.erase(bus->commandStream.begin() + i);
55  }
56  }
57 }
Rtu(Bus *prmBus, Logger *prmLogger)
Definition: RTU.cpp:3
std::vector< Command > commandStream
Definition: Bus.h:20
Definition: Logger.h:5
void FrameMove(float fElapsedTime) override
Definition: RTU.cpp:8
std::vector< bool > Transmitting
(8) Manual radio transmitter keying, or CVR/DFDR synchronization reference;
Definition: Bus.h:53
Definition: Bus.h:12
std::string name
command name
Definition: Command.h:11
Abstract base class for modules By definition, instruments don&#39;t do any of the work (they don&#39;t modif...
Definition: Module.h:11
Definition: Command.h:5
void Log(const char *msg, Level level=Info, int errorCode=0)
These have to be in this order.
Definition: Logger.cpp:16
bool bvalue
Definition: Command.h:23
Bus * bus
Definition: Module.h:17
int ivalue
Definition: Command.h:21
Logger * logger
Definition: Module.h:177
float delay
wait number of seconds before executing command
Definition: Command.h:8