mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
(WiP) Timestamp measures for data updates
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include "utils.h"
|
||||
#include "dcstools.h"
|
||||
#include "luatools.h"
|
||||
#include "measure.h"
|
||||
|
||||
namespace State
|
||||
{
|
||||
@@ -28,88 +29,86 @@ public:
|
||||
Unit(json::value json, int ID);
|
||||
~Unit();
|
||||
|
||||
/********** Public methods **********/
|
||||
int getID() { return ID; }
|
||||
|
||||
void updateExportData(json::value json);
|
||||
void updateMissionData(json::value json);
|
||||
json::value json(bool fullRefresh);
|
||||
json::value getData(int time);
|
||||
|
||||
/********** Base data **********/
|
||||
void setAI(bool newAI) { AI = newAI; }
|
||||
void setAI(bool newAI) { AI = newAI; addMeasure(L"AI", json::value(newAI)); }
|
||||
void setName(wstring newName) { name = newName; addMeasure(L"name", json::value(newName));}
|
||||
void setUnitName(wstring newUnitName) { name = newUnitName; addMeasure(L"unitName", json::value(newUnitName));}
|
||||
void setGroupName(wstring newGroupName) { name = newGroupName; addMeasure(L"groupName", json::value(newGroupName));}
|
||||
void setAlive(bool newAlive) { alive = newAlive; addMeasure(L"alive", json::value(newAlive));}
|
||||
void setType(json::value newType) { type = newType; addMeasure(L"type", newType);}
|
||||
void setCountry(int newCountry) { country = newCountry; addMeasure(L"country", json::value(newCountry));}
|
||||
bool getAI() { return AI; }
|
||||
void setName(wstring newName){name = newName};
|
||||
wstring getName() { return name; }
|
||||
void setUnitName(wstring newName){name = newName};
|
||||
wstring getUnitName() { return unitName; }
|
||||
void setGroupName(wstring newName){name = newName};
|
||||
wstring getGroupName() { return groupName; }
|
||||
void setAlive(bool newAlive) { alive = newAlive; }
|
||||
bool getAlive() { return alive; }
|
||||
void setType(json::value newType) { type = newType; }
|
||||
json::value getType() { return type; }
|
||||
void setCountry(int newCountry) { country = newCountry; }
|
||||
int getCountry() { return country; }
|
||||
|
||||
/********** Flight data **********/
|
||||
void setLatitude(double newLatitude) {latitude = newLatitude;}
|
||||
void setLatitude(double newLatitude) {latitude = newLatitude; addMeasure(L"latitude", json::value(newLatitude));}
|
||||
void setLongitude(double newLongitude) {longitude = newLongitude; addMeasure(L"longitude", json::value(newLongitude));}
|
||||
void setAltitude(double newAltitude) {altitude = newAltitude; addMeasure(L"altitude", json::value(newAltitude));}
|
||||
void setHeading(double newHeading) {heading = newHeading; addMeasure(L"heading", json::value(newHeading));}
|
||||
void setSpeed(double newSpeed) {speed = newSpeed; addMeasure(L"speed", json::value(newSpeed));}
|
||||
double getLatitude() { return latitude; }
|
||||
void setLongitude(double newLatitude) {longitude = newLongitude;}
|
||||
double getLongitude() { return longitude; }
|
||||
void setAltitude(double newAltitude) {altitude = newAltitude;}
|
||||
double getAltitude() { return altitude; }
|
||||
void setHeading(double newHeading) {heading = newHeading;}
|
||||
double getHeading() { return heading; }
|
||||
void setSpeed(double newSpeed) {speed = newSpeed;}
|
||||
double getSpeed() {return speed; }
|
||||
double getSpeed() { return speed; }
|
||||
|
||||
/********** Mission data **********/
|
||||
void setFuel(double newFuel) { fuel = newFuel;}
|
||||
double getFuel() {return fuel;}
|
||||
void setAmmo(json::value newAmmo) { ammo = newAmmo; }
|
||||
json::value getAmmo { return ammo; }
|
||||
void setTargets(json::value newTargets) {targets = newTargets;}
|
||||
void setFuel(double newFuel) { fuel = newFuel; addMeasure(L"fuel", json::value(newFuel));}
|
||||
void setAmmo(json::value newAmmo) { ammo = newAmmo; addMeasure(L"ammo", json::value(newAmmo));}
|
||||
void setTargets(json::value newTargets) {targets = newTargets; addMeasure(L"targets", json::value(newTargets));}
|
||||
void setHasTask(bool newHasTask) { hasTask = newHasTask; addMeasure(L"hasTask", json::value(newHasTask));}
|
||||
void setCoalitionID(int newCoalitionID) { coalitionID = newCoalitionID; addMeasure(L"coalition", json::value(newCoalitionID)); } // TODO fix
|
||||
void setFlags(json::value newFlags) { flags = newFlags; addMeasure(L"flags", json::value(newFlags));}
|
||||
double getFuel() { return fuel; }
|
||||
json::value getAmmo() { return ammo; }
|
||||
json::value getTargets() { return targets; }
|
||||
void setHasTask(bool newHasTask) { hasTask = newHasTask;}
|
||||
bool getHasTask() { return hasTask; }
|
||||
void setCoalitionID(int newCoalitionID) { coalitionID = newCoalitionID; }
|
||||
int getCoalitionID() { return coalitionID; }
|
||||
void setFlags(json::value newFlags) { flags = newFlags; }
|
||||
json::value getFlags() { return flags; }
|
||||
|
||||
/********** Formation data **********/
|
||||
void setIsLeader(bool newIsLeader);
|
||||
bool getIsLeader() { return isLeader; }
|
||||
void setIsWingman(bool newIsWingman);
|
||||
bool getIsWingman() { return isWingman; }
|
||||
void setLeader(Unit *newLeader) { leader = newLeader; }
|
||||
Unit* getLeader() {return leader;}
|
||||
void setWingmen(vector<Unit *> newWingmen) { wingmen = newWingmen; }
|
||||
vector<Unit*> getWingmen() {return wingmen;}
|
||||
void setFormation(wstring newFormation) { formation = newFormation; }
|
||||
wstring getFormation() { return formation; }
|
||||
void setLeader(Unit *newLeader) { leader = newLeader; addMeasure(L"leader", json::value("")); } // TODO fix
|
||||
void setWingmen(vector<Unit*> newWingmen) { wingmen = newWingmen; addMeasure(L"wingmen", json::value("")); } // TODO fix
|
||||
void setFormation(wstring newFormation) { formation = newFormation; addMeasure(L"formation", json::value(formation));}
|
||||
void setFormationOffset(Offset formationOffset);
|
||||
Offset getFormationoffset() {return formationOffset;}
|
||||
|
||||
bool getIsLeader() { return isLeader; }
|
||||
bool getIsWingman() { return isWingman; }
|
||||
Unit* getLeader() { return leader; }
|
||||
vector<Unit*> getWingmen() { return wingmen; }
|
||||
wstring getFormation() { return formation; }
|
||||
Offset getFormationoffset() { return formationOffset; }
|
||||
|
||||
/********** Task data **********/
|
||||
void setCurrentTask(wstring newCurrentTask) { currentTask = newCurrentTask; }
|
||||
wstring getCurrentTask() { return currentTask; }
|
||||
virtual void setTargetSpeed(double newSpeed) { targetSpeed = newSpeed; }
|
||||
virtual double getTargetSpeed() { return targetSpeed; };
|
||||
virtual void setTargetAltitude(double newAltitude) { targetAltitude = newAltitude; }
|
||||
virtual double getTargetAltitude() { return targetAltitude; };
|
||||
void setActiveDestination(Coords newActiveDestination) { activeDestination = newActiveDestination; }
|
||||
Coords getActiveDestination() { return activeDestination; }
|
||||
void setCurrentTask(wstring newCurrentTask) { currentTask = newCurrentTask;addMeasure(L"currentTask", json::value(newCurrentTask)); }
|
||||
virtual void setTargetSpeed(double newTargetSpeed) { targetSpeed = newTargetSpeed; addMeasure(L"targetSpeed", json::value(newTargetSpeed));}
|
||||
virtual void setTargetAltitude(double newTargetAltitude) { targetAltitude = newTargetAltitude; addMeasure(L"targetAltitude", json::value(newTargetAltitude));} //TODO fix, double definition
|
||||
void setActiveDestination(Coords newActiveDestination) { activeDestination = newActiveDestination; addMeasure(L"activeDestination", json::value("")); } // TODO fix
|
||||
void setActivePath(list<Coords> newActivePath);
|
||||
list<Coords> getPath() {return activePath}
|
||||
void setActiveDestination(Coords newActiveDestination) { activeDestination = newActiveDestination; }
|
||||
void setTargetID(int newTargetID) { targetID = newTargetID; addMeasure(L"targetID", json::value(newTargetID));}
|
||||
wstring getCurrentTask() { return currentTask; }
|
||||
virtual double getTargetSpeed() { return targetSpeed; };
|
||||
virtual double getTargetAltitude() { return targetAltitude; };
|
||||
Coords getActiveDestination() { return activeDestination; }
|
||||
void setTarget(int targetID);
|
||||
wstring getTarget();
|
||||
list<Coords> getActivePath() { return activePath; }
|
||||
int getTargetID() { return targetID; }
|
||||
|
||||
/********** Options data **********/
|
||||
void setROE(wstring newROE);
|
||||
wstring getROE() {return ROE;}
|
||||
void setReactionToThreat(wstring newReactionToThreat);
|
||||
wstring getROE() { return ROE; }
|
||||
wstring getReactionToThreat() {return reactionToThreat;}
|
||||
|
||||
/********** Control functions **********/
|
||||
@@ -120,15 +119,11 @@ public:
|
||||
virtual void setState(int newState) { state = newState; };
|
||||
void resetTask();
|
||||
|
||||
/********** Other functions **********/
|
||||
void setHasNewData(bool newHasNewData) { hasNewData = newHasNewData; }
|
||||
virtual wstring getCategory() { return L"No category"; };
|
||||
bool isTargetAlive();
|
||||
bool getHasNewData() { return hasNewData; }
|
||||
|
||||
protected:
|
||||
int ID;
|
||||
|
||||
map<wstring, Measure*> measures;
|
||||
|
||||
/********** Base data **********/
|
||||
bool AI = false;
|
||||
wstring name = L"undefined";
|
||||
@@ -178,9 +173,11 @@ protected:
|
||||
|
||||
/********** Other **********/
|
||||
Coords oldPosition = Coords(0); // Used to approximate speed
|
||||
bool hasNewData = false;
|
||||
int newDataCounter = 0;
|
||||
|
||||
/********** Functions **********/
|
||||
virtual wstring getCategory() { return L"No category"; };
|
||||
wstring getTargetName();
|
||||
bool isTargetAlive();
|
||||
virtual void AIloop() = 0;
|
||||
void addMeasure(wstring key, json::value value);
|
||||
};
|
||||
|
||||
19
src/core/include/measure.h
Normal file
19
src/core/include/measure.h
Normal file
@@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
#include "framework.h"
|
||||
|
||||
class Measure
|
||||
{
|
||||
public:
|
||||
Measure(json::value value, int time): value(value), time(time) {};
|
||||
|
||||
void setValue(json::value newValue) { value = newValue; }
|
||||
void setTime(int newTime) { time = newTime; }
|
||||
json::value getValue() { return value; }
|
||||
int getTime() { return time; }
|
||||
|
||||
private:
|
||||
json::value value;
|
||||
int time;
|
||||
|
||||
};
|
||||
|
||||
@@ -11,9 +11,10 @@ public:
|
||||
~UnitsManager();
|
||||
|
||||
Unit* getUnit(int ID);
|
||||
void expireMeasures();
|
||||
void updateExportData(lua_State* L);
|
||||
void updateMissionData(json::value missionData);
|
||||
void updateAnswer(json::value& answer, bool fullRefresh);
|
||||
void getData(json::value& answer, int time);
|
||||
void deleteUnit(int ID);
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user