mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
Added functions to set TACAN and radio frequencies
This commit is contained in:
@@ -105,12 +105,16 @@ public:
|
||||
void setTargetID(int newTargetID) { targetID = newTargetID; addMeasure(L"targetID", json::value(newTargetID));}
|
||||
void setIsTanker(bool newIsTanker) { isTanker = newIsTanker; addMeasure(L"isTanker", json::value(newIsTanker));}
|
||||
void setIsAWACS(bool newIsAWACS) { isAWACS = newIsAWACS; addMeasure(L"isAWACS", json::value(newIsAWACS));}
|
||||
void setRadioOn(bool newRadioOn) { radioOn = newRadioOn; addMeasure(L"radioOn", json::value(newRadioOn)); }
|
||||
void setTACANOn(bool newTACANOn) { TACANOn = newTACANOn; addMeasure(L"TACANOn", json::value(newTACANOn)); }
|
||||
void setRadioFrequency(int newRadioFrequency) { radioFrequency = newRadioFrequency; addMeasure(L"radioFrequency", json::value(newRadioFrequency)); }
|
||||
void setTACANChannel(int newTACANChannel) { TACANChannel = newTACANChannel; addMeasure(L"TACANChannel", json::value(newTACANChannel)); }
|
||||
void setTACANXY(wstring newTACANXY) { TACANXY = newTACANXY; addMeasure(L"TACANXY", json::value(newTACANXY)); }
|
||||
void setTACANCallsign(wstring newTACANCallsign) { TACANCallsign = newTACANCallsign; addMeasure(L"TACANCallsign", json::value(newTACANCallsign)); }
|
||||
void setTACANOn(bool newTACANOn);
|
||||
void setTACANChannel(int newTACANChannel);
|
||||
void setTACANXY(wstring newTACANXY);
|
||||
void setTACANCallsign(wstring newTACANCallsign);
|
||||
void setTACAN();
|
||||
void setRadioOn(bool newRadioOn);
|
||||
void setRadioFrequency(int newRadioFrequency);
|
||||
void setRadioCallsign(int newRadioCallsign);
|
||||
void setRadioCallsignNumber(int newRadioCallsignNumber);
|
||||
void setRadio();
|
||||
wstring getCurrentTask() { return currentTask; }
|
||||
virtual double getTargetSpeed() { return targetSpeed; };
|
||||
virtual double getTargetAltitude() { return targetAltitude; };
|
||||
@@ -119,12 +123,14 @@ public:
|
||||
int getTargetID() { return targetID; }
|
||||
bool getIsTanker() { return isTanker; }
|
||||
bool getIsAWACS() { return isAWACS; }
|
||||
bool setRadioOn() { return radioOn; }
|
||||
bool setTACANOn() { return TACANOn; }
|
||||
int setRadioFrequency() { return radioFrequency; }
|
||||
int setTACANChannel() { return TACANChannel; }
|
||||
wstring setTACANXY() { return TACANXY; }
|
||||
wstring setTACANCallsign() { return TACANCallsign; }
|
||||
bool getTACANOn() { return TACANOn; }
|
||||
int getTACANChannel() { return TACANChannel; }
|
||||
wstring getTACANXY() { return TACANXY; }
|
||||
wstring getTACANCallsign() { return TACANCallsign; }
|
||||
bool getRadioOn() { return radioOn; }
|
||||
int getRadioFrequency() { return radioFrequency; }
|
||||
int getRadioCallsign() { return radioCallsign; }
|
||||
int getRadioCallsignNumber() { return radioCallsignNumber; }
|
||||
|
||||
/********** Options data **********/
|
||||
void setROE(wstring newROE);
|
||||
@@ -186,12 +192,14 @@ protected:
|
||||
int targetID = NULL;
|
||||
bool isTanker = false;
|
||||
bool isAWACS = false;
|
||||
bool radioOn = false;
|
||||
bool TACANOn = false;
|
||||
int radioFrequency = 0;
|
||||
int TACANChannel = 0;
|
||||
wstring TACANXY = "X";
|
||||
wstring TACANCallsign = "TKR";
|
||||
wstring TACANXY = L"X";
|
||||
wstring TACANCallsign = L"TKR";
|
||||
bool radioOn = false;
|
||||
int radioFrequency = 0;
|
||||
int radioCallsign = 0;
|
||||
int radioCallsignNumber = 1;
|
||||
|
||||
/********** Options data **********/
|
||||
wstring ROE = L"";
|
||||
|
||||
@@ -264,11 +264,20 @@ void Scheduler::handleRequest(wstring key, json::value value)
|
||||
{
|
||||
unit->setIsTanker(value[L"isTanker"].as_bool());
|
||||
unit->setIsAWACS(value[L"isAWACS"].as_bool());
|
||||
unit->setRadioOn(value[L"radioOn"].as_bool());
|
||||
unit->setTACANOn(value[L"TACANOn"].as_bool());
|
||||
unit->setTACANCallsign(value[L"TACANCallsign"].as_string());
|
||||
|
||||
unit->setTACANOn(true); // TODO Remove
|
||||
unit->setTACANChannel(value[L"TACANChannel"].as_number().to_int32());
|
||||
unit->setTACANXY(value[L"TACANXY"].as_string());
|
||||
unit->setTACANCallsign(value[L"TACANCallsign"].as_string());
|
||||
unit->setTACAN();
|
||||
|
||||
unit->setRadioOn(true); // TODO Remove
|
||||
unit->setRadioFrequency(value[L"radioFrequency"].as_number().to_int32());
|
||||
unit->setRadioCallsign(value[L"radioCallsign"].as_number().to_int32());
|
||||
unit->setRadioCallsignNumber(value[L"radioCallsignNumber"].as_number().to_int32());
|
||||
unit->setRadio();
|
||||
|
||||
unit->resetActiveDestination();
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -346,4 +346,90 @@ void Unit::landAt(Coords loc) {
|
||||
clearActivePath();
|
||||
pushActivePathBack(loc);
|
||||
setState(State::LAND);
|
||||
}
|
||||
}
|
||||
|
||||
void Unit::setTACANOn(bool newTACANOn) {
|
||||
TACANOn = newTACANOn;
|
||||
addMeasure(L"TACANOn", json::value(newTACANOn));
|
||||
}
|
||||
|
||||
void Unit::setTACANChannel(int newTACANChannel) {
|
||||
TACANChannel = newTACANChannel;
|
||||
addMeasure(L"TACANChannel", json::value(newTACANChannel));
|
||||
}
|
||||
|
||||
void Unit::setTACANXY(wstring newTACANXY) {
|
||||
TACANXY = newTACANXY;
|
||||
addMeasure(L"TACANXY", json::value(newTACANXY));
|
||||
}
|
||||
void Unit::setTACANCallsign(wstring newTACANCallsign) {
|
||||
TACANCallsign = newTACANCallsign;
|
||||
addMeasure(L"TACANCallsign", json::value(newTACANCallsign));
|
||||
}
|
||||
|
||||
void Unit::setRadioOn(bool newRadioOn) {
|
||||
radioOn = newRadioOn;
|
||||
addMeasure(L"radioOn", json::value(newRadioOn));
|
||||
}
|
||||
|
||||
void Unit::setRadioFrequency(int newRadioFrequency) {
|
||||
radioFrequency = newRadioFrequency;
|
||||
addMeasure(L"radioFrequency", json::value(newRadioFrequency));
|
||||
}
|
||||
|
||||
void Unit::setRadioCallsign(int newRadioCallsign) {
|
||||
radioCallsign = newRadioCallsign;
|
||||
addMeasure(L"radioCallsign", json::value(newRadioCallsign));
|
||||
}
|
||||
|
||||
void Unit::setRadioCallsignNumber(int newRadioCallsignNumber) {
|
||||
radioCallsignNumber = newRadioCallsignNumber;
|
||||
addMeasure(L"radioCallsignNumber", json::value(newRadioCallsignNumber));
|
||||
}
|
||||
|
||||
void Unit::setTACAN()
|
||||
{
|
||||
std::wostringstream commandSS;
|
||||
commandSS << "{"
|
||||
<< "id = 'ActivateBeacon',"
|
||||
<< "params = {"
|
||||
<< "type = 4,"
|
||||
<< "system = 4,"
|
||||
<< "name = Olympus_TACAN,"
|
||||
<< "callsign = " << TACANCallsign << ", "
|
||||
<< "frequency = " << TACANChannelToFrequency(TACANChannel, TACANXY) << ","
|
||||
<< "}"
|
||||
<< "}";
|
||||
Command* command = dynamic_cast<Command*>(new SetCommand(ID, commandSS.str()));
|
||||
scheduler->appendCommand(command);
|
||||
}
|
||||
|
||||
void Unit::setRadio()
|
||||
{
|
||||
{
|
||||
std::wostringstream commandSS;
|
||||
commandSS << "{"
|
||||
<< "id = 'SetFrequency',"
|
||||
<< "params = {"
|
||||
<< "modulation = 0," // TODO Allow selection
|
||||
<< "frequency = " << TACANChannelToFrequency(TACANChannel, TACANXY) << ","
|
||||
<< "}"
|
||||
<< "}";
|
||||
Command* command = dynamic_cast<Command*>(new SetCommand(ID, commandSS.str()));
|
||||
scheduler->appendCommand(command);
|
||||
}
|
||||
|
||||
{
|
||||
std::wostringstream commandSS;
|
||||
commandSS << "{"
|
||||
<< "id = 'SetCallsign',"
|
||||
<< "params = {"
|
||||
<< "callname = " << radioCallsign << ","
|
||||
<< "number = " << radioCallsignNumber << ","
|
||||
<< "}"
|
||||
<< "}";
|
||||
Command* command = dynamic_cast<Command*>(new SetCommand(ID, commandSS.str()));
|
||||
scheduler->appendCommand(command);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,4 +8,5 @@ void DllExport LogError(lua_State* L, string message);
|
||||
void DllExport Log(lua_State* L, string message, int level);
|
||||
int DllExport dostring_in(lua_State* L, string target, string command);
|
||||
map<int, json::value> DllExport getAllUnits(lua_State* L);
|
||||
int DllExport TACANChannelToFrequency(int channel, wstring XY);
|
||||
|
||||
|
||||
@@ -94,7 +94,6 @@ exit:
|
||||
return units;
|
||||
}
|
||||
|
||||
|
||||
int dostring_in(lua_State* L, string target, string command)
|
||||
{
|
||||
lua_getglobal(L, "net");
|
||||
@@ -102,4 +101,10 @@ int dostring_in(lua_State* L, string target, string command)
|
||||
lua_pushstring(L, target.c_str());
|
||||
lua_pushstring(L, command.c_str());
|
||||
return lua_pcall(L, 2, 0, 0);
|
||||
}
|
||||
|
||||
int TACANChannelToFrequency(int channel, wstring XY)
|
||||
{
|
||||
int basef = (XY == L"X" && channel > 63) || (XY == L"Y" && channel < 64) ? 1087000000 : 961000000;
|
||||
return basef + 1000000 * channel;
|
||||
}
|
||||
Reference in New Issue
Block a user