You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
243 lines
5.3 KiB
243 lines
5.3 KiB
#ifndef __OBJECT_MASTBAUM_HEADERS__
|
|
#define __OBJECT_MASTBAUM_HEADERS__
|
|
|
|
#include "../../alg/lgs/mask.h"
|
|
#include "../../data/net/clientPort.h"
|
|
#include "../../data/protocol/protocolLGS.h"
|
|
#include "../../hardware/soc/general/3DLRF.h"
|
|
#include "../base/basicDualThread.h"
|
|
#include "../base/basicEventHeap.h"
|
|
#include "../base/basicLogCollection.h"
|
|
#include "../base/basicMutex.h"
|
|
#include "../base/basicObject.h"
|
|
#include "../base/basicPosition.h"
|
|
#include "../base/basicSettingsProvider.h"
|
|
|
|
#include <stdint.h>
|
|
#include <WinSock2.h>
|
|
|
|
#define LGS_TIMEOUT_COUNT 100
|
|
#define LGS_MAX_IDLE_DELAY 40 // x10 msec
|
|
#define LGS_MIN_IDLE_DELAY 1 // x10 msec
|
|
|
|
#define USE_MUTEX true
|
|
#define DONT_USE_MUTEX false
|
|
|
|
#define LGS_SETTINGS_NODE_MASTER "LGS_DEVICE_MASTER"
|
|
#define LGS_SETTINGS_NODE_SLAVE "LGS_DEVICE_SLAVE"
|
|
#define LGS_SET_FLIP "FLIP_SIZE"
|
|
#define LGS_SET_OFFSET "OFFSET_SIZE"
|
|
#define LGS_SET_ORDER "ORDER_SIZE"
|
|
#define LGS_SET_DELTA "DELTA_SIZE"
|
|
#define LGS_SET_SST "SST_SIZE"
|
|
#define LGS_SET_ADDRESS "IP_ADDRESS"
|
|
#define LGS_SET_PORT "IP_PORT"
|
|
|
|
class GLRadar;
|
|
class RangeMapWidget;
|
|
|
|
typedef struct S_DEVICE_STATUS
|
|
{
|
|
E_LGS_DATA_INTEGRITY_FLAG ErrorOpStatus;
|
|
E_LGS_CMD ErrorOpCode;
|
|
E_LGS_CMD CurrentOperation;
|
|
E_LGS_CMD PendingOperation;
|
|
E_LGS_STAGE ComStatus;
|
|
E_LGS_STAGE Status;
|
|
uint8_t DoneByPercents;
|
|
bool ProgressIsActive;
|
|
} DEVICE_STATUS, *PDEVICE_STATUS;
|
|
|
|
class objectMASTBAUM : public basicObject, basicDualThread
|
|
{
|
|
private:
|
|
|
|
basicLogCollection * m_pLog;
|
|
basicEventHeap * m_pEventHeap;
|
|
config_setting_t * m_pSettings;
|
|
|
|
protocolLGS_CLIENT * m_oProtocol;
|
|
clientPort * m_pTransport;
|
|
CSTR m_pHost;
|
|
int m_nPort;
|
|
|
|
PLGS_PARAMETERS m_pLGS_PARAMETERS;
|
|
E_CLIENT_WORK_MODE m_eWorkMode;
|
|
DEVICE_STATUS m_sDeviceStatus;
|
|
SOFTWARE_INFO m_sDeviceSoftNFO;
|
|
|
|
// bool m_bGetParamBusyFlag;
|
|
// bool m_bDeviceIsSynched;
|
|
|
|
bool m_bTransportStatus;
|
|
bool m_bMasksAreLoadded;
|
|
bool m_bIsMaster;
|
|
|
|
int m_nBusyCounter;
|
|
int m_nIdleCounter;
|
|
int m_nIdleTarget;
|
|
basicMutex m_mPackageMutex;
|
|
basicMutex m_mStatusMutex;
|
|
basicMutex m_mDataMutex;
|
|
basicPosition * m_pPosition;
|
|
thresholdNode * m_pThresholdData;
|
|
uint32_t m_nFullBorderDataIndex;
|
|
uint8_t m_nFullBorderKernelIndex;
|
|
|
|
GLRadar * m_pRadarWidget;
|
|
RangeMapWidget * m_pMapWidget;
|
|
uint8_t m_nDevicePolyCount;
|
|
uint8_t m_nCurrentPolyID;
|
|
ShadowMask * m_pShadow;
|
|
|
|
bool setOperation(E_LGS_CMD opCode, bool fNOW = false);
|
|
bool forceOperation(E_LGS_CMD opCode);
|
|
void setCompelition(uint8_t Perc);
|
|
E_LGS_CMD getOperation(void);
|
|
void promoteOperation(void);
|
|
void completeOperation(bool success = true);
|
|
void cleanOperation(void);
|
|
void comSetIdle(bool useMutex = true);
|
|
void comSetBusy(bool useMutex = true);
|
|
bool comIsIdle(void);
|
|
void cleanDataTH(void);
|
|
|
|
protected:
|
|
|
|
void m_fThreadAProc(void);
|
|
void m_fThreadBProc(void);
|
|
|
|
public:
|
|
|
|
// explicit objectLGS( PLGS_PARAMETERS Settings, basicTransport *Transport);
|
|
explicit objectMASTBAUM(config_setting_t * Settings = NULL, bool Master = true);
|
|
~objectMASTBAUM();
|
|
bool create(void);
|
|
bool startGetScanData(uint8_t kID = 0, uint32_t * th_zone = NULL);
|
|
bool startGetParameters(uint32_t timeout = 0);
|
|
bool startUploadMask(void);
|
|
bool startDeviceReset(bool FullReset = true);
|
|
bool startStopMotors(void);
|
|
bool startStartMotors(void);
|
|
bool startMasksStatus(bool Active);
|
|
uint8_t getCompelition(void);
|
|
|
|
SOFTWARE_INFO * getSoftwareInfo(void)
|
|
{
|
|
return &m_sDeviceSoftNFO;
|
|
}
|
|
|
|
E_LGS_CMD getCurrentCMD(void)
|
|
{
|
|
E_LGS_CMD tVal;
|
|
m_mStatusMutex.lock();
|
|
tVal = m_sDeviceStatus.CurrentOperation;
|
|
m_mStatusMutex.unlock();
|
|
return tVal;
|
|
}
|
|
|
|
E_LGS_STAGE getCurrentSTG(void)
|
|
{
|
|
E_LGS_STAGE tVal;
|
|
m_mStatusMutex.lock();
|
|
tVal = m_sDeviceStatus.Status;
|
|
m_mStatusMutex.unlock();
|
|
return tVal;
|
|
}
|
|
|
|
PLGS_PARAMETERS getSettings(void)
|
|
{
|
|
return m_pLGS_PARAMETERS;
|
|
}
|
|
|
|
CSTR getHost(void)
|
|
{
|
|
return m_pHost;
|
|
}
|
|
|
|
int getPort(void)
|
|
{
|
|
return m_nPort;
|
|
}
|
|
|
|
bool getDeviceStatus(DEVICE_STATUS & STAT);
|
|
|
|
ShadowMask * getMask(void)
|
|
{
|
|
return m_pShadow;
|
|
}
|
|
|
|
bool setHost(CSTR Host);
|
|
bool setPort(int Port);
|
|
bool setSettings(PLGS_PARAMETERS Params);
|
|
|
|
bool isMaster(void)
|
|
{
|
|
return m_bIsMaster;
|
|
}
|
|
|
|
bool areMasksLoadded(void)
|
|
{
|
|
if (! m_bMasksAreLoadded)
|
|
{
|
|
SLEEP(10);
|
|
}
|
|
return m_bMasksAreLoadded;
|
|
}
|
|
|
|
bool areMasksActive(void)
|
|
{
|
|
if (m_bMasksAreLoadded)
|
|
{
|
|
if (m_pShadow != NULL)
|
|
{
|
|
return m_pShadow->isActive();
|
|
};
|
|
};
|
|
return false;
|
|
}
|
|
|
|
bool isConnected(void)
|
|
{
|
|
bool tVal;
|
|
m_mStatusMutex.lock();
|
|
tVal = (m_sDeviceStatus.Status > STG_DISCONNECTED);
|
|
m_mStatusMutex.unlock();
|
|
return tVal;
|
|
}
|
|
|
|
void attachRadarWidget(GLRadar * ptr)
|
|
{
|
|
m_pRadarWidget = ptr;
|
|
}
|
|
|
|
void attachMapWidget(RangeMapWidget * ptr)
|
|
{
|
|
m_pMapWidget = ptr;
|
|
}
|
|
|
|
basicPosition * getPosition(void)
|
|
{
|
|
return m_pPosition;
|
|
}
|
|
|
|
void updateSettings(void);
|
|
|
|
// New Order
|
|
thresholdNode * grabDataAccess(void);
|
|
void releaseDataAccess(void);
|
|
|
|
bool lastTaskComplete(void);
|
|
void cleanLastTaskStatus(void);
|
|
};
|
|
|
|
typedef struct S_SENSOR_INFO
|
|
{
|
|
uint8_t deviceType;
|
|
uint16_t portID;
|
|
uint32_t addressIP;
|
|
} SENSOR_INFO;
|
|
|
|
typedef std::vector<objectMASTBAUM *> vectorMBSensors;
|
|
|
|
#endif
|