Browse Source

Mekorot step

AGP
Evgeny Gagua at Mercury 6 years ago
parent
commit
a7daeaa63b
  1. 3
      Projects/MEKOROT/MEKOROT.vcxproj
  2. 9
      Projects/MEKOROT/MEKOROT.vcxproj.filters
  3. 47
      Projects/MEKOROT/MEKOROT_Kernel.cpp
  4. 11
      lib/App/CudaWare_64_DNN_Learning/main_window.ui
  5. 2
      lib/alg/lgs/mask.h
  6. 8
      lib/components/base/basicCamera.cpp
  7. 4
      lib/components/base/basicFunctionality.cpp
  8. 4
      lib/components/base/basicFunctionality.h
  9. 2
      lib/components/base/basicLIBAV.h
  10. 4
      lib/components/base/basicTransport.h
  11. 13
      lib/data/protocol/protocol.cpp
  12. 23
      lib/data/protocol/protocol.h
  13. 12
      lib/hardware/soc/general/3DLRF.h
  14. 10
      lib/hardware/uart/serialPort.cpp
  15. 31
      lib/hardware/uart/serialSOL.cpp
  16. 20
      lib/hardware/uart/serialSOL.h

3
Projects/MEKOROT/MEKOROT.vcxproj

@ -181,9 +181,12 @@
<ClCompile Include="..\..\lib\data\media\videoNode.cpp" />
<ClCompile Include="..\..\lib\data\protocol\protocol.cpp" />
<ClCompile Include="..\..\lib\data\protocol\protocolLGS.cpp" />
<ClCompile Include="..\..\lib\data\protocol\protocolLGSm.cpp" />
<ClCompile Include="..\..\lib\data\storage\storageProvider.cpp" />
<ClCompile Include="..\..\lib\data\transport\transportSerial.cpp" />
<ClCompile Include="..\..\lib\data\transport\transportSocket.cpp" />
<ClCompile Include="..\..\lib\hardware\uart\serialPort.cpp" />
<ClCompile Include="..\..\lib\hardware\uart\serialSOL.cpp" />
<ClCompile Include="MEKOROT.cpp" />
<ClCompile Include="MEKOROT_Kernel.cpp" />
</ItemGroup>

9
Projects/MEKOROT/MEKOROT.vcxproj.filters

@ -111,6 +111,15 @@
<ClCompile Include="..\..\lib\data\protocol\protocolLGS.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\lib\data\protocol\protocolLGSm.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\lib\hardware\uart\serialSOL.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\lib\data\transport\transportSocket.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="MEKOROT.h">

47
Projects/MEKOROT/MEKOROT_Kernel.cpp

@ -3,6 +3,30 @@
#define LOG( X ) m_pLog->Log( "KRNL", this, X )
#define LOG_ERROR( X ) m_pLog->Log( "KRNL", this, _LOG_ERROR, X )
bool getconchar(KEY_EVENT_RECORD& krec) {
DWORD cc, NOF;
INPUT_RECORD irec;
HANDLE h = GetStdHandle(STD_INPUT_HANDLE);
if (h == NULL) {
return false; // console not found
};
if (!GetNumberOfConsoleInputEvents(h, &NOF)) return false;
if( NOF ) for(int i=0;i<NOF; i++)
{
ReadConsoleInput(h, &irec, 1, &cc);
if (irec.EventType == KEY_EVENT
&& ((KEY_EVENT_RECORD&)irec.Event).bKeyDown
)//&& ! ((KEY_EVENT_RECORD&)irec.Event).wRepeatCount )
{
krec = (KEY_EVENT_RECORD&)irec.Event;
return true;
}
}
return false; //future ????
};
mekorotKernel::mekorotKernel(config_setting_t* ptr) : protocolLGS_CLIENT(), basicThread(), basicEngine() {
m_pLog = basicLogCollection::getInstance();
m_pSettings = basicSettingsProvider::getInstance()->getSubNode(ptr, (CSTR)"KERNEL");
@ -12,6 +36,7 @@ mekorotKernel::mekorotKernel(config_setting_t* ptr) : protocolLGS_CLIENT(), basi
m_nSerialSpeed = 19200;
m_bDeviceID[0] = m_bDeviceID[1] = m_bDeviceID[2] = -1;
m_bDeviceFlags[0] = m_bDeviceFlags[1] = m_bDeviceFlags[2] = false;
m_bDeviceTO[0] = m_bDeviceTO[1] = m_bDeviceTO[2] = 0;
};
mekorotKernel::~mekorotKernel() {
@ -29,7 +54,7 @@ bool mekorotKernel::init(void){
basicSettingsProvider::getInstance()->compromise();
if (pSetting == NULL) {
LOG_ERROR("Failure while adding setting!");
return -1;
return false;
};
config_setting_set_string(pSetting, m_pSerialDevice);
};
@ -41,7 +66,7 @@ bool mekorotKernel::init(void){
basicSettingsProvider::getInstance()->compromise();
if (pSetting == NULL) {
LOG_ERROR("Failure while adding setting!");
return -1;
return false;
};
config_setting_set_int(pSetting, m_nSerialSpeed );
};
@ -53,7 +78,7 @@ bool mekorotKernel::init(void){
basicSettingsProvider::getInstance()->compromise();
if (pSetting == NULL) {
LOG_ERROR("Failure while adding setting!");
return -1;
return false;
};
config_setting_set_int(pSetting, m_bDeviceID[0]);
};
@ -65,7 +90,7 @@ bool mekorotKernel::init(void){
basicSettingsProvider::getInstance()->compromise();
if (pSetting == NULL) {
LOG_ERROR("Failure while adding setting!");
return -1;
return false;
};
config_setting_set_int(pSetting, m_bDeviceID[1]);
};
@ -77,7 +102,7 @@ bool mekorotKernel::init(void){
basicSettingsProvider::getInstance()->compromise();
if (pSetting == NULL) {
LOG_ERROR("Failure while adding setting!");
return -1;
return false;
};
config_setting_set_int(pSetting, m_bDeviceID[2]);
};
@ -90,6 +115,18 @@ bool mekorotKernel::init(void){
void mekorotKernel::m_fThreadProc(void){
m_bThreadStatus = TH_WORKING;
while (m_bThreadStatus < TH_ENDED) {
KEY_EVENT_RECORD krec;
if( getconchar(krec) ){
//Parse KeyBoard Input
char tBuffer[128];
sprintf(tBuffer, "Key Stroke Code: %d", krec.wVirtualKeyCode);
LOG(tBuffer);
if (krec.wVirtualKeyCode == 81 || krec.wVirtualKeyCode == 75) { // q Or k
LOG("Exit by Operator Request!");
m_bThreadStatus = TH_ENDED;
continue;
};
};
switch( m_bStage ) {
case MEKOROT_KRNL_STG_CONNECT:{
if (m_pSerial == NULL) {

11
lib/App/CudaWare_64_DNN_Learning/main_window.ui

@ -191,6 +191,9 @@
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextBesideIcon</enum>
</property>
<property name="floatable">
<bool>true</bool>
</property>
@ -202,11 +205,19 @@
</attribute>
</widget>
<action name="actionNew_Network">
<property name="icon">
<iconset resource="../../resources/cudawork_resources.qrc">
<normaloff>:/general/bulb.png</normaloff>:/general/bulb.png</iconset>
</property>
<property name="text">
<string>New Network</string>
</property>
</action>
<action name="actionOpen">
<property name="icon">
<iconset resource="../../resources/cudawork_resources.qrc">
<normaloff>:/menu/PNG/devices/030.png</normaloff>:/menu/PNG/devices/030.png</iconset>
</property>
<property name="text">
<string>Open</string>
</property>

2
lib/alg/lgs/mask.h

@ -5,7 +5,7 @@
#include "../../hardware/soc/general/3DLRF.h"
#include "../../components/base/basicLogCollection.h"
#if defined( __linux__ ) && !defined( __GUI__ )
#if ( defined( __linux__ ) && !defined( __GUI__ ) ) || defined( _MEKOROT_ )
typedef struct{
private:
int16_t m_x;

8
lib/components/base/basicCamera.cpp

@ -315,9 +315,11 @@ void basicCamera::updateSettings(void){
void basicCamera::dispatchEvent( basicEvent *Evt ){
if( Evt->m_eClass == EVT_CLASS_SENSOR ) {
switch (Evt->m_eType){
case EVT_TARGET:
case EVT_TARGET_WHITE:
case EVT_TARGET_BLACK:
case EVT_TARGET_1D:
case EVT_TARGET_2D_WHITE:
case EVT_TARGET_2D_BLACK:
case EVT_TARGET_3D_WHITE:
case EVT_TARGET_3D_BLACK:
case EVT_ALARM:
CLIENT_EVENT *tData;
tData = ( CLIENT_EVENT *) Evt->m_pEvtData;

4
lib/components/base/basicFunctionality.cpp

@ -197,7 +197,11 @@ CSTR getTStr( CSTR Fmt ){
}
//RetVal =(CSTR) malloc( strlen(DateStr) +1 );
//if( RetVal != NULL ) strcpy( RetVal, DateStr );
#ifdef __linux__
return strdup(DateStr);
#else
return _strdup(DateStr);
#endif
};
#ifdef __linux__

4
lib/components/base/basicFunctionality.h

@ -16,7 +16,9 @@
#else
//#include <winsock2.h>
//#include <ws2tcpip.h>
#define WIN32_LEAN_AND_MEAN
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <atlbase.h>
#include <windows.h>
#include <VersionHelpers.h>

2
lib/components/base/basicLIBAV.h

@ -9,7 +9,7 @@
#include <math.h>
#ifdef _OPENCV_
#include <opencv2/opencv.hpp>
#include <opencv/highgui.h>
//#include <opencv/highgui.h>
//using namespace cv;
#else
#ifdef _SDL_

4
lib/components/base/basicTransport.h

@ -8,7 +8,9 @@
#include "basicLogCollection.h"
#ifdef DEBUG
#define DUBUG_COMMUNICATION
#ifndef DUBUG_COMMUNICATION
#define DUBUG_COMMUNICATION
#endif
#endif
class protocolParser;

13
lib/data/protocol/protocol.cpp

@ -8,23 +8,27 @@
protocolParser::protocolParser() : m_mBufferProtectorMutex(){
m_pLog = basicLogCollection::getInstance();
m_eConnectionStatus = CS_UNKNOWN;
m_pParserBuffer = (U8*) malloc(PROTOCOL_PARSER_BUFFER_SIZE);
m_nParserDataCount = 0;
m_bStatus = 0;
m_pCustomHandler = NULL;
m_bBufferAltered = false;
m_bStatus = 1;
#ifdef PROTOCOL_PARSER_IN_THREAD
m_bParserThreadStatus = TH_PRE_INIT;
m_eConnectionStatus = CS_UNKNOWN;
#endif
};
protocolParser::~protocolParser(){
# ifdef DEBUG
LOG("Destructor Begin");
# endif
#ifdef PROTOCOL_PARSER_IN_THREAD
if (m_bParserThreadStatus > TH_ARMED ) {
waitParserThreadEnd( true );
};
#endif
m_mBufferProtectorMutex.unlock();
if (m_bParserThreadStatus < TH_ENDED ) {
waitParserThreadEnd( true );
@ -39,6 +43,7 @@ protocolParser::~protocolParser(){
bool protocolParser::create(void){
if (m_pParserBuffer != NULL) {
#ifdef PROTOCOL_PARSER_IN_THREAD
if (m_bParserThreadStatus == TH_PRE_INIT) {
m_bParserThreadStatus = TH_ARMED;
#if defined( __linux__ ) || defined(WIN_PTHREAD)
@ -61,6 +66,7 @@ bool protocolParser::create(void){
LOG_ERROR("Thread object not ready to be created.");
return false;
};
#endif
return true;
} else return false;
};
@ -94,6 +100,8 @@ bool protocolParser::parse( U8 *Buffer, size_t BufferSize ){
memcpy( m_pParserBuffer+m_nParserDataCount, Buffer, BufferSize );
m_nParserDataCount+=BufferSize;
rv = m_bBufferAltered = true;
#ifndef PROTOCOL_PARSER_IN_THREAD
#endif
};
m_mBufferProtectorMutex.unlock();
};
@ -106,6 +114,7 @@ void protocolParser::dataEraser( U8 *&tPtr ){
tPtr = NULL;
};
#ifdef PROTOCOL_PARSER_IN_THREAD
void protocolParser::m_fParserThreadProc(void){
int RetVal;
m_bParserThreadStatus = TH_WORKING;
@ -208,7 +217,7 @@ void protocolParser::waitParserThreadEnd(bool forced){
#endif
};
#endif //#ifndef PROTOCOL_PARSER_IN_THREAD
bool protocolParser::getPackage( U8 **Package, size_t *Size ){
if( this ) {
m_mBufferProtectorMutex.lock();

23
lib/data/protocol/protocol.h

@ -7,12 +7,15 @@
#include "../../components/base/basicTransport.h"
#include "../../components/base/basicThread.h"
#define PROTOCOL_PARSER_IN_THREAD
#define PROTO_TAG_GROUP "PROTOCOL"
#define PROTO_QUEUE_MAX_PACKAGES 32
#define PROTOCOL_PARSER_BUFFER_SIZE 102400
#ifdef DEBUG
#define DUBUG_COMMUNICATION
#ifndef DUBUG_COMMUNICATION
#define DUBUG_COMMUNICATION
#endif
#endif
typedef struct S_protocolPackage{
@ -30,17 +33,19 @@ class protocolParser {
size_t m_nParserDataCount;
bool m_bBufferAltered;
basicMutex m_mBufferProtectorMutex;
#if defined( __linux__ ) || defined(WIN_PTHREAD)
pthread_t m_sParserThreadHandler;
static void *m_fParserThreadEntryPoint(void *);
#else
HANDLE m_hParserThreadHandle;
DWORD m_dwThreadID;
static DWORD WINAPI m_fParserThreadEntryPoint( LPVOID lpParameter );
#endif
#ifdef PROTOCOL_PARSER_IN_THREAD
#if defined( __linux__ ) || defined(WIN_PTHREAD)
pthread_t m_sParserThreadHandler;
static void *m_fParserThreadEntryPoint(void *);
#else
HANDLE m_hParserThreadHandle;
DWORD m_dwThreadID;
static DWORD WINAPI m_fParserThreadEntryPoint( LPVOID lpParameter );
#endif
thredStatus m_bParserThreadStatus;
void m_fParserThreadProc(void);
void waitParserThreadEnd( bool forced = false );
#endif
protected:
basicTransport *m_oDataTransport;
CONNECTION_STATUS m_eConnectionStatus;

12
lib/hardware/soc/general/3DLRF.h

@ -620,14 +620,14 @@ enum {
inline void make3Ddeg(uint32_t sid, float &az, float &el, bool master = true ){
az = ((float)(TH_LINE_NODES - (sid % TH_LINE_NODES))) * (B_DEGREE_FOV / (float)M_SCAN_POINTS);
if ( master ){
el = 90.0 - (float)(sid / TH_LINE_NODES) * (Q_DEGREE_FOV / Q_SCAN_COUNT) - Q_SHIFT_DOWN_FOV;
el = 90.0f - (float)(sid / TH_LINE_NODES) * (Q_DEGREE_FOV / Q_SCAN_COUNT) - Q_SHIFT_DOWN_FOV;
} else {
el = 90.0 - (Q_SCAN_COUNT - (float)(sid / TH_LINE_NODES)) * (Q_DEGREE_FOV / Q_BLOCK_COUNT) - Q_SHIFT_DOWN_FOV;
el = 90.0f - (Q_SCAN_COUNT - (float)(sid / TH_LINE_NODES)) * (Q_DEGREE_FOV / Q_BLOCK_COUNT) - Q_SHIFT_DOWN_FOV;
};
if( el < 0 ) {
el *= -1.0;
az = az + 180.0;
if( az > 360.0 ) az = az - 360.0;
el *= -1.0f;
az = az + 180.0f;
if( az > 360.0f ) az = az - 360.0f;
};
};
@ -686,7 +686,7 @@ enum {
inline uint32_t makeSID(int kID, int qID, int bID){
int cid;
int cqid;
int mid;
//int mid;
int ccp;
int opp;
cqid = qID % Q_Q_INTERLEAVE;

10
lib/hardware/uart/serialPort.cpp

@ -289,11 +289,11 @@ bool serialPort::HW_init( CSTR DevicePath, int Speed ){
CommTimeouts.WriteTotalTimeoutMultiplier = 10;
CommTimeouts.WriteTotalTimeoutConstant = 100;
*/
CommTimeouts.ReadIntervalTimeout = 0UL;
CommTimeouts.ReadTotalTimeoutMultiplier = 0UL;
CommTimeouts.ReadTotalTimeoutConstant = 0UL;
CommTimeouts.WriteTotalTimeoutMultiplier = 0UL;
CommTimeouts.WriteTotalTimeoutConstant = 0UL;
CommTimeouts.ReadIntervalTimeout = 1UL;
CommTimeouts.ReadTotalTimeoutMultiplier = 1UL;
CommTimeouts.ReadTotalTimeoutConstant = 1UL;
CommTimeouts.WriteTotalTimeoutMultiplier = 1UL;
CommTimeouts.WriteTotalTimeoutConstant = 1UL;
// Set the time-out parameters for all read and write operations on the port.
if (!SetCommTimeouts(m_ioFID, &CommTimeouts)){
sprintf(MsgBuffer, "Port [%s] Could not create the read thread.(SetCommTimeouts Failed)", m_sDevicePath);

31
lib/hardware/uart/serialSOL.cpp

@ -8,10 +8,13 @@ serialSOL::serialSOL( SOL_TYPE t ): transportSocket(){
m_eSolType = t;
m_bInitComplete = false;
m_nSocketFD = -1;
#ifdef __linux__
m_sServerAddr;
m_sClientAddr;
memset( &m_sServerAddr, 0, sizeof( m_sServerAddr ) );
memset( &m_sClientAddr, 0, sizeof( m_sClientAddr ) );
#endif
};
serialSOL::~serialSOL(){
@ -24,6 +27,7 @@ bool serialSOL::create( CSTR address, uint16_t port, int Speed ){
break;
};
case SOL_UDP_CLIENT:{
#ifdef __linux__
// Creating socket file descriptor
if ( (m_nSocketFD = socket(AF_INET, SOCK_DGRAM, 0)) < 0 ) {
LOG_ERROR("Socket Creation Failed!");
@ -34,13 +38,28 @@ bool serialSOL::create( CSTR address, uint16_t port, int Speed ){
m_sServerAddr.sin_family = AF_INET;
m_sServerAddr.sin_addr.s_addr = INADDR_ANY;
m_sServerAddr.sin_port = htons( port );
#else
WSADATA wsaData;
// Initialize Winsock version 2.2
if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0) {
char tBuff[128];
sprintf(tBuff, "WSAStartup failed with error %ld", WSAGetLastError());
LOG_ERROR(tBuff);
return false;
} else {
char tBuff[128];
sprintf(tBuff, "The Winsock DLL status is %s.", wsaData.szSystemStatus);
LOG(tBuff);
};
#endif
break;
};
case SOL_TCP_SERVER:{
break;
};
case SOL_UDP_SERVER:{
#ifdef __linux__
// Creating socket file descriptor
if ( (m_nSocketFD = socket( AF_INET, SOCK_DGRAM, 0 )) < 0 ) {
LOG_ERROR("Socket Creation Failed!");
@ -57,6 +76,7 @@ bool serialSOL::create( CSTR address, uint16_t port, int Speed ){
LOG_ERROR("Bind Failed");
return false;
};
#endif
break;
};
};
@ -66,7 +86,7 @@ bool serialSOL::create( CSTR address, uint16_t port, int Speed ){
int serialSOL::sendBlock( unsigned char *Data, int DataSize ){
if( !m_bInitComplete || !m_bConnected ) return -1; // Exit after unsuccess reconnect
int RetVal;
int RetVal = 0;
if( m_nSocketFD > -1 ){
#ifdef DUBUG_COMMUNICATION
@ -74,6 +94,7 @@ int serialSOL::sendBlock( unsigned char *Data, int DataSize ){
sprintf(cBuffer,"Write into Socket %d bytes", DataSize );
LOG(cBuffer);
#endif
#ifdef __linux__
socklen_t addr_len = sizeof( m_sClientAddr );
RetVal = sendto( m_nSocketFD, (const char *)Data, DataSize, MSG_CONFIRM, (const struct sockaddr *) &m_sClientAddr, addr_len );
@ -86,7 +107,7 @@ int serialSOL::sendBlock( unsigned char *Data, int DataSize ){
setConnectionStatus( CS_DISCONNECTED );
return -1;
};
#endif
if( RetVal < 0 ) RetVal = 0;
#ifdef DUBUG_COMMUNICATION
@ -112,8 +133,9 @@ int serialSOL::recptBlock( unsigned char *Buffer, int *BufferLength ){
setConnectionStatus( CS_DISCONNECTED );
return -1; // Exit after unsuccess reconnect
};
int RetVal;
int RetVal = 0;
if( m_nSocketFD > -1 ) {
#ifdef __linux__
socklen_t addr_len = sizeof( m_sClientAddr ); //len is value/resuslt
RetVal = recvfrom( m_nSocketFD, (char *)Buffer, MAXIMAL_SOCKET_PACKET_LENGTH, MSG_WAITALL, ( struct sockaddr *) &m_sClientAddr, &addr_len );
if( RetVal < 1 ){
@ -128,6 +150,7 @@ int serialSOL::recptBlock( unsigned char *Buffer, int *BufferLength ){
return -1;
};
};
#endif
} else {
LOG_ERROR("Not Connected!");
*BufferLength = 0;

20
lib/hardware/uart/serialSOL.h

@ -17,13 +17,17 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h> // File control definitions
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#ifdef __linux__
#include <unistd.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#else
#include <winsock2.h>
#endif
#ifdef DEBUG
//#define _DEBUG_SOL_COMMUNICATION_
@ -50,10 +54,14 @@ class serialSOL: public transportSocket {
SOL_TYPE m_eSolType;
bool m_bInitComplete;
int m_nSocketFD;
#ifdef __linux__
struct sockaddr_in m_sServerAddr;
struct sockaddr_in m_sClientAddr;
#else
WSADATA wsaData;
SOCKET ReceivingSocket;
SOCKADDR_IN ReceiverAddr;
#endif
protected:
int sendBlock( unsigned char *Data, int DataSize );
int recptBlock( unsigned char *Buffer, int *BufferLength );

Loading…
Cancel
Save