Initial check-in

This commit is contained in:
Duc
2025-03-14 07:47:07 -07:00
parent 04f78fcca7
commit b59c6c743d
56 changed files with 6547 additions and 9 deletions

63
.gitattributes vendored Normal file
View File

@@ -0,0 +1,63 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto
###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp
###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary
###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary
###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain

368
.gitignore vendored
View File

@@ -1,15 +1,365 @@
# ---> Linux ## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
/HWIL_Assistant/src/CommonLib/
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Oo]ut/
[Ll]og/
[Ll]ogs/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# ASP.NET Scaffolding
ScaffoldingReadMe.txt
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
coverage*.json
coverage*.xml
coverage*.info
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*~ *~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# temporary files which can be created if a process still has a handle open of a deleted file # Including strong name files can present a security risk
.fuse_hidden* # (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# KDE directory preferences # Since there are multiple workflows, uncomment next line to ignore bower_components
.directory # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# Linux trash folder which might appear on any partition or disk # RIA/Silverlight projects
.Trash-* Generated_Code/
# .nfs files are created when an open file is removed but is still being accessed # Backup & report files from converting an old project file
.nfs* # to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
# Fody - auto-generated XML schema
FodyWeavers.xsd

View File

@@ -0,0 +1,129 @@
QT += core gui
QT += network
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG(debug, debug|release){
DESTDIR = build_x64_debug
} else {
DESTDIR = build_x64_release
}
OBJECTS_DIR = $${DESTDIR}/OBJ
MOC_DIR = $${DESTDIR}/MOC
RCC_DIR = $${DESTDIR}/RCC
UI_DIR = $${DESTDIR}/UI
TARGET = HWIL_Assistant
CONFIG += c++11
DEFINES += LINUX_PLATFORM
QT += testlib
SOURCES += \
src/Comm/UdpSocketMgr.cpp \
src/AutomationMessages/AreYouThereCmdMessage.cpp \
src/AutomationMessages/AreYouThereRspMessage.cpp \
src/AutomationMessages/AutomationMsgHandler.cpp \
src/AutomationMessages/AutomationMsgParser.cpp \
src/AutomationMessages/GenericRspMessage.cpp \
src/AutomationMessages/KwScenarioStartedMessage.cpp \
src/AutomationMessages/KwScenarioStoppedMessage.cpp \
src/AutomationMessages/Message.cpp \
src/AutomationMessages/MessageHeader.cpp \
src/AutomationMessages/WaitForLastTaskCompletionCmdMessage.cpp \
src/Comm/UdpSocket.cpp \
src/CommonLib/Exceptions/Exception.cpp \
src/CommonLib/Exceptions/TimeoutError.cpp \
src/CommonLib/Lib/Condition.cpp \
src/Common/Constants.cpp \
src/CommonLib/Lib/ErrorLog.cpp \
src/CommonLib/Lib/EventNames.cpp \
src/CommonLib/Lib/IniFile.cpp \
src/CommonLib/Lib/LockMutex.cpp \
src/CommonLib/Lib/Mutex.cpp \
src/CommonLib/Lib/OSObject.cpp \
src/CommonLib/Lib/Util/DateTimeUtil.cpp \
src/CommonLib/Lib/Util/FileSystemUtil.cpp \
src/CommonLib/Lib/Util/MiscUtil.cpp \
src/CommonLib/Lib/Util/StringUtil.cpp \
src/CommonLib/Proc/Proc.cpp \
src/CommonLib/Lib/Timestamp.cpp \
src/Common/Util.cpp \
src/CommonLib/Threading/Thread.cpp \
src/Config/ConfigFileManager.cpp \
src/LinuxProc.cpp \
src/Threads/FileTransferThread.cpp \
src/Threads/NetworkingThread.cpp \
src/Threads/RunAppThread.cpp \
src/UI/FileTransferDialog.cpp \
src/UI/MainWindow.cpp \
src/main.cpp \
HEADERS += \
src/Comm/UdpSocketMgr.hpp \
src/AutomationMessages/AreYouThereCmdMessage.hpp \
src/AutomationMessages/AreYouThereRspMessage.hpp \
src/AutomationMessages/AutomationMsgHandler.hpp \
src/AutomationMessages/AutomationMsgParser.hpp \
src/AutomationMessages/GenericRspMessage.hpp \
src/AutomationMessages/KwScenarioStartedMessage.hpp \
src/AutomationMessages/KwScenarioStoppedMessage.hpp \
src/AutomationMessages/Message.hpp \
src/AutomationMessages/MessageHeader.hpp \
src/AutomationMessages/MessageIDs.hpp \
src/AutomationMessages/WaitForLastTaskCompletionCmdMessage.hpp \
src/Comm/UdpSocket.hpp \
src/CommonLib/Exceptions/Exception.hpp \
src/CommonLib/Exceptions/TimeoutError.hpp \
src/CommonLib/Lib/Condition.hpp \
src/Common/Constants.hpp \
src/CommonLib/Lib/CustomDataTypes.hpp \
src/CommonLib/Lib/ErrorLog.hpp \
src/CommonLib/Lib/EventNames.hpp \
src/CommonLib/Lib/IniFile.hpp \
src/CommonLib/Lib/LockMutex.hpp \
src/CommonLib/Lib/Mutex.hpp \
src/CommonLib/Lib/OSObject.hpp \
src/CommonLib/Lib/Util/DateTimeUtil.hpp \
src/CommonLib/Lib/Util/FileSystemUtil.hpp \
src/CommonLib/Lib/Util/MiscUtil.hpp \
src/CommonLib/Lib/Util/StringUtil.hpp \
src/CommonLib/Proc/Proc.hpp \
src/CommonLib/Lib/Timestamp.hpp \
src/Common/Util.hpp \
src/CommonLib/Threading/Thread.hpp \
src/Config/ConfigFileManager.hpp \
src/LinuxProc.hpp \
src/Threads/FileTransferThread.hpp \
src/Threads/NetworkingThread.hpp \
src/Threads/RunAppThread.hpp \
src/UI/FileTransferDialog.hpp \
src/UI/MainWindow.h
FORMS += \
src/UI/FileTransferDialog.ui \
src/UI/mainwindow.ui
INCLUDEPATH += src/ \
src/UI/ \
src/Computers/ \
src/Comm/ \
src/Config/ \
src/Threads/ \
src/CommonLib/Comm/ \
src/CommonLib/Exceptions/ \
src/CommonLib/Lib/ \
src/CommonLib/Lib/Util/ \
src/CommonLib/Proc/ \
src/CommonLib/Threading/ \
src/Common/ \
src/AutomationMessages/
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
DISTFILES += \
src/Config/config.ini

View File

@@ -0,0 +1,11 @@
#!/bin/bash
length=${#1};
if [[ $length -eq 0 ]]
then
echo "Please specify a tracked file to ignore";
exit 1
fi
git update-index --skip-worktree $1

View File

@@ -0,0 +1,3 @@
#!/bin/bash
git ls-tree -r master --name-only

View File

@@ -0,0 +1,11 @@
#!/bin/bash
length=${#1};
if [[ $length -eq 0 ]]
then
echo "Please specify a tracked file to ignore";
exit 1
fi
git update-index --no-skip-worktree $1

View File

@@ -0,0 +1,4 @@
Before building, go to project settings -> Build Settings and disable Shadow Build
Shadow Build will put all build output files in a location outside of project folder relative to home directory
This project is set to output files in the project folder so we can easily locate the files

View File

@@ -0,0 +1,106 @@
#include <sstream>
#include <string.h>
#include "AreYouThereCmdMessage.hpp"
#include "Exception.hpp"
#include "Util.hpp"
#include "LinuxProc.hpp"
#include "IniFile.hpp"
#include "AreYouThereRspMessage.hpp"
#include "Condition.hpp"
#include "UdpSocketMgr.hpp"
#include <QDir>
#include <QStringList>
#include <QDirIterator>
#include <QCoreApplication>
//------------------------------------------------------------------------
AreYouThereCmdMessage::AreYouThereCmdMessage():
Message(MessageIDs::ARE_YOU_THERE_CMD, "ARE_YOU_THERE_CMD")
{
}
//------------------------------------------------------------------------
AreYouThereCmdMessage::AreYouThereCmdMessage(const AreYouThereCmdMessage& copy) :
Message(copy)
{
}
//------------------------------------------------------------------------
AreYouThereCmdMessage::~AreYouThereCmdMessage()
{
}
//------------------------------------------------------------------------
Message* AreYouThereCmdMessage::cloneSelf()
{
AreYouThereCmdMessage* pMsg = new AreYouThereCmdMessage(*this);
return pMsg;
}
//------------------------------------------------------------------------
void AreYouThereCmdMessage::executeMessage()
{
try
{
Condition& commandExecutingEvent = LinuxProc::Instance().getEvent(EventNames::COMMAND_EXECUTTION_IN_PROGRESS);
Condition& completeEvent = LinuxProc::Instance().getEvent(EventNames::COMMAND_EXECUTION_COMPLETE);
completeEvent.reset();
if (commandExecutingEvent.timedWait(0,0)) // a command is current executing
{
completeEvent.wait(); // wait until current command finish executing
}
// signal this command is currently executing to prevent any other command from executing
commandExecutingEvent.signal();
AreYouThereRspMessage rsp(QCoreApplication::applicationFilePath().toStdString());
UdpSocketMgr::Instance().sendAMessage(rsp);
commandExecutingEvent.reset();
completeEvent.signal();
}
catch (Exception& e)
{
e.buildStackTrace(Q_FUNC_INFO);
throw e;
}
}
//------------------------------------------------------------------------
void AreYouThereCmdMessage::formatData(unsigned char* pData)
{
// Here's how the data is formatted
// each data item is preceded by a 4-byte header which tells us the size of the data item
// 1 data item will have [header][data]
// 2 data items will have [header][data][header][data]
unsigned int dataLen = 0;
// we want update total size of the entire message
m_header.setMessageLength(static_cast<unsigned short>(dataLen));
m_header.format(pData);
}
//------------------------------------------------------------------------
void AreYouThereCmdMessage::parseData(const unsigned char*)
{
}
//------------------------------------------------------------------------
std::string AreYouThereCmdMessage::toString() const
{
std::stringstream ss;
ss << Message::toString() << ". No member data";
return ss.str();
}

View File

@@ -0,0 +1,118 @@
// UNCLASSIFIED
/*-------------------------------------------------------------------------
RAYTHEON PROPRIETARY: THIS DOCUMENT CONTAINS DATA OR INFORMATION
PROPRIETARY TO RAYTHEON COMPANY AND IS RESTRICTED TO USE ONLY BY PERSONS
AUTHORIZED BY RAYTHEON COMPANY IN WRITING TO USE IT. DISCLOSURE TO
UNAUTHORIZED PERSONS WOULD LIKELY CAUSE SUBSTANTIAL COMPETITIVE HARM TO
RAYTHEON COMPANY'S BUSINESS POSITION. NEITHER SAID DOCUMENT NOR ITS
CONTENTS SHALL BE FURNISHED OR DISCLOSED TO OR COPIED OR USED BY PERSONS
OUTSIDE RAYTHEON COMPANY WITHOUT THE EXPRESS WRITTEN APPROVAL OF RAYTHEON
COMPANY.
THIS PROPRIETARY NOTICE IS NOT APPLICABLE IF DELIVERED TO THE U.S.
GOVERNMENT.
UNPUBLISHED WORK - COPYRIGHT RAYTHEON COMPANY.
-------------------------------------------------------------------------*/
#pragma once
#include "Message.hpp"
#include "MessageIDs.hpp"
#include "MessageHeader.hpp"
class AreYouThereCmdMessage : public Message
{
public:
//>---------------------------------------------------------------------------
// Function: AreYouThereCmdMessage
//
// Purpose: constructor
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
AreYouThereCmdMessage();
//>---------------------------------------------------------------------------
// Function: AreYouThereCmdMessage
//
// Purpose: copy constructor
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
AreYouThereCmdMessage(const AreYouThereCmdMessage &copy);
//>---------------------------------------------------------------------------
// Function: ~AreYouThereCmdMessage
//
// Purpose: destructor
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
virtual ~AreYouThereCmdMessage();
//>---------------------------------------------------------------------------
// Function: ExecuteMessage
//
// Purpose:
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
virtual void executeMessage();
//>---------------------------------------------------------------------------
// Function: ToString
//
// Purpose:
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
virtual std::string toString() const;
protected:
//>---------------------------------------------------------------------------
// Function: CloneSelf
//
// Purpose:
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
virtual Message* cloneSelf();
//>---------------------------------------------------------------------------
// Function: FormatData
//
// Purpose:
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
virtual void formatData(unsigned char* pData);
//>---------------------------------------------------------------------------
// Function: ParseData
//
// Purpose:
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
virtual void parseData(const unsigned char* pData);
private:
// do not allow
AreYouThereCmdMessage &operator=(const AreYouThereCmdMessage &rhs);
};

View File

@@ -0,0 +1,106 @@
#include <sstream>
#include <string.h>
#include "AreYouThereRspMessage.hpp"
#include "Exception.hpp"
#include "StringUtil.hpp"
#include "MiscUtil.hpp"
#include "FileSystemUtil.hpp"
#include "Proc.hpp"
#include "IniFile.hpp"
#include "GenericRspMessage.hpp"
#include "Condition.hpp"
#include "Proc.hpp"
#include "UdpSocketMgr.hpp"
#include <QRegExp>
#include <QDir>
#include <QStringList>
#include <QDirIterator>
//------------------------------------------------------------------------
AreYouThereRspMessage::AreYouThereRspMessage(std::string appPath):
Message(MessageIDs::ARE_YOU_THERE_RSP, "ARE_YOU_THERE_RSP"),
m_appPath(appPath)
{
}
//------------------------------------------------------------------------
AreYouThereRspMessage::AreYouThereRspMessage(const AreYouThereRspMessage& copy) :
Message(copy),
m_appPath(copy.m_appPath)
{
}
//------------------------------------------------------------------------
AreYouThereRspMessage::~AreYouThereRspMessage()
{
}
//------------------------------------------------------------------------
Message* AreYouThereRspMessage::cloneSelf()
{
AreYouThereRspMessage* pMsg = new AreYouThereRspMessage(*this);
return pMsg;
}
//------------------------------------------------------------------------
void AreYouThereRspMessage::executeMessage()
{
std::map<std::string,std::string> users = Util::Misc::GetUsersOfRunningProcess(Util::FileSystem::ExtractFilename(m_appPath));
// an instance of the this app is already running, we want to quit this instance
throw Exception(Q_FUNC_INFO, "An instance of this application is already running by " + users.begin()->second + " (PID: " + users.begin()->first + ")");
}
//------------------------------------------------------------------------
void AreYouThereRspMessage::formatData(unsigned char* pData)
{
// Here's how the data is formatted
// each data item is preceded by a 4-byte header which tells us the size of the data item
// 1 data item will have [header][data]
// 2 data items will have [header][data][header][data]
unsigned int dataLen = 0;
const unsigned char* pTempDataStart = pData + getHeaderLength();
buildByteArray(&pTempDataStart, m_appPath.c_str(), m_appPath.length(), dataLen);
// we want update total size of the entire message
m_header.setMessageLength(static_cast<unsigned short>(dataLen));
m_header.format(pData);
}
//------------------------------------------------------------------------
void AreYouThereRspMessage::parseData(const unsigned char* pData)
{
bool selfThrown = false;
const unsigned char* pTempDataStart = pData;
const unsigned char* pTempDataEnd = pData + m_header.getMessageLength() - m_header.getHeaderLength() - 1;
int sizeOfData = 0;
try {
sizeOfData = getNextDataItem(&pTempDataStart, pTempDataEnd, sizeOfData);
m_appPath = Util::Strings::ByteArrayToString(const_cast<unsigned char*>(pTempDataStart), sizeOfData);
} catch (Exception& e) {
if (!selfThrown)
e.buildStackTrace(Q_FUNC_INFO);
throw e;
}
}
//------------------------------------------------------------------------
std::string AreYouThereRspMessage::toString() const
{
std::stringstream ss;
ss << Message::toString() << "AppPath: " << m_appPath;
return ss.str();
}

View File

@@ -0,0 +1,120 @@
// UNCLASSIFIED
/*-------------------------------------------------------------------------
RAYTHEON PROPRIETARY: THIS DOCUMENT CONTAINS DATA OR INFORMATION
PROPRIETARY TO RAYTHEON COMPANY AND IS RESTRICTED TO USE ONLY BY PERSONS
AUTHORIZED BY RAYTHEON COMPANY IN WRITING TO USE IT. DISCLOSURE TO
UNAUTHORIZED PERSONS WOULD LIKELY CAUSE SUBSTANTIAL COMPETITIVE HARM TO
RAYTHEON COMPANY'S BUSINESS POSITION. NEITHER SAID DOCUMENT NOR ITS
CONTENTS SHALL BE FURNISHED OR DISCLOSED TO OR COPIED OR USED BY PERSONS
OUTSIDE RAYTHEON COMPANY WITHOUT THE EXPRESS WRITTEN APPROVAL OF RAYTHEON
COMPANY.
THIS PROPRIETARY NOTICE IS NOT APPLICABLE IF DELIVERED TO THE U.S.
GOVERNMENT.
UNPUBLISHED WORK - COPYRIGHT RAYTHEON COMPANY.
-------------------------------------------------------------------------*/
#pragma once
#include "Message.hpp"
#include "MessageIDs.hpp"
#include "MessageHeader.hpp"
class AreYouThereRspMessage : public Message
{
public:
//>---------------------------------------------------------------------------
// Function: AreYouThereRspMessage
//
// Purpose: constructor
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
AreYouThereRspMessage(std::string appPath = "");
//>---------------------------------------------------------------------------
// Function: AreYouThereRspMessage
//
// Purpose: copy constructor
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
AreYouThereRspMessage(const AreYouThereRspMessage &copy);
//>---------------------------------------------------------------------------
// Function: ~AreYouThereRspMessage
//
// Purpose: destructor
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
virtual ~AreYouThereRspMessage();
//>---------------------------------------------------------------------------
// Function: ExecuteMessage
//
// Purpose:
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
virtual void executeMessage();
//>---------------------------------------------------------------------------
// Function: ToString
//
// Purpose:
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
virtual std::string toString() const;
protected:
//>---------------------------------------------------------------------------
// Function: CloneSelf
//
// Purpose:
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
virtual Message* cloneSelf();
//>---------------------------------------------------------------------------
// Function: FormatData
//
// Purpose:
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
virtual void formatData(unsigned char* pData);
//>---------------------------------------------------------------------------
// Function: ParseData
//
// Purpose:
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
virtual void parseData(const unsigned char* pData);
private:
// do not allow
AreYouThereRspMessage &operator=(const AreYouThereRspMessage &rhs);
std::string m_appPath;
};

View File

@@ -0,0 +1,177 @@
#include <cerrno>
#include <cstdio>
#include <string.h>
#include <string>
#include <sstream>
#include <QByteArray>
#include <QString>
#include "AutomationMsgHandler.hpp"
#include "Exception.hpp"
#include "MessageHeader.hpp"
#include "MessageIDs.hpp"
#include "ErrorLog.hpp"
#include "Util.hpp"
#include "LinuxProc.hpp"
#include "IniFile.hpp"
#include "GenericRspMessage.hpp"
#include "Condition.hpp"
#include "AreYouThereCmdMessage.hpp"
#include "WaitForLastTaskCompletionCmdMessage.hpp"
#include "KwScenarioStartedMessage.hpp"
#include "KwScenarioStoppedMessage.hpp"
//-----------------------------------------------------------------------------
AutomationMsgHandler::AutomationMsgHandler()
{
}
//-----------------------------------------------------------------------------
AutomationMsgHandler::~AutomationMsgHandler(){}
//-----------------------------------------------------------------------------
AutomationMsgHandler& AutomationMsgHandler::instance()
{
static AutomationMsgHandler handler;
return handler;
}
//-----------------------------------------------------------------------------
void AutomationMsgHandler::handleMsg(const unsigned char* pData, const unsigned int& id)
{
try
{
MessageIDs::MsgIds msgId = (MessageIDs::MsgIds)id;
if (msgId != MessageIDs::WAIT_FOR_COMPLETION_CMD)
WaitForLastTaskCompletionCmdMessage::s_commandCompletionSuccess = true;
if (msgId == MessageIDs::ARE_YOU_THERE_CMD)
{
handleAreYouThereMessage(pData);
}
else if (msgId == MessageIDs::SCENARIO_STARTED_CMD)
{
handleKwScenarioStartedCMessage(pData);
}
else if (msgId == MessageIDs::SCENARIO_STOPPED_CMD)
{
handleKwScenarioStoppedCMessage(pData);
}
else if (msgId == MessageIDs::WAIT_FOR_COMPLETION_CMD)
{
handleWaitForLastTaskCompletionMessage(pData);
}
else
{
std::stringstream ss;
ss << "unknown message id: " << id;
throw Exception (Q_FUNC_INFO, ss.str());
}
}
catch (Exception& e)
{
LinuxProc::Instance().getEvent(EventNames::COMMAND_EXECUTTION_IN_PROGRESS).reset();
LinuxProc::Instance().getEvent(EventNames::COMMAND_EXECUTION_COMPLETE).signal();
WaitForLastTaskCompletionCmdMessage::s_commandCompletionSuccess = false;
e.buildStackTrace(Q_FUNC_INFO);
throw e;
}
}
//-----------------------------------------------------------------------------
void AutomationMsgHandler::handleAreYouThereMessage(const unsigned char* pData)
{
try {
AreYouThereCmdMessage cmd;
cmd.parse(pData);
if (LinuxProc::Instance().getConfig().getBool("GENERAL", "VERBOSE_LOGGING"))
ErrorLog::Instance().log(cmd.toString(), false, ErrorLog::INFO);
cmd.executeMessage();
}
catch (Exception& e)
{
e.buildStackTrace(Q_FUNC_INFO);
throw e;
}
}
//-----------------------------------------------------------------------------
void AutomationMsgHandler::handleKwScenarioStartedCMessage(const unsigned char *pData)
{
try {
KwScenarioStartedMessage cmd;
cmd.parse(pData);
if (LinuxProc::Instance().getConfig().getBool("GENERAL", "VERBOSE_LOGGING"))
ErrorLog::Instance().log(cmd.toString(), false, ErrorLog::INFO);
cmd.executeMessage();
}
catch (Exception& e)
{
e.buildStackTrace(Q_FUNC_INFO);
throw e;
}
}
//-----------------------------------------------------------------------------
void AutomationMsgHandler::handleKwScenarioStoppedCMessage(const unsigned char *pData)
{
try {
KwScenarioStoppedMessage cmd;
cmd.parse(pData);
if (LinuxProc::Instance().getConfig().getBool("GENERAL", "VERBOSE_LOGGING"))
ErrorLog::Instance().log(cmd.toString(), false, ErrorLog::INFO);
cmd.executeMessage();
}
catch (Exception& e)
{
e.buildStackTrace(Q_FUNC_INFO);
throw e;
}
}
//-----------------------------------------------------------------------------
void AutomationMsgHandler::handleWaitForLastTaskCompletionMessage(const unsigned char* pData)
{
try {
WaitForLastTaskCompletionCmdMessage cmd;
cmd.parse(pData);
if (LinuxProc::Instance().getConfig().getBool("GENERAL", "VERBOSE_LOGGING"))
ErrorLog::Instance().log(cmd.toString(), false, ErrorLog::INFO);
cmd.executeMessage();
}
catch (Exception& e)
{
e.buildStackTrace(Q_FUNC_INFO);
throw e;
}
}

View File

@@ -0,0 +1,114 @@
// UNCLASSIFIED
/*-------------------------------------------------------------------------
RAYTHEON PROPRIETARY: THIS DOCUMENT CONTAINS DATA OR INFORMATION
PROPRIETARY TO RAYTHEON COMPANY AND IS RESTRICTED TO USE ONLY BY PERSONS
AUTHORIZED BY RAYTHEON COMPANY IN WRITING TO USE IT. DISCLOSURE TO
UNAUTHORIZED PERSONS WOULD LIKELY CAUSE SUBSTANTIAL COMPETITIVE HARM TO
RAYTHEON COMPANY'S BUSINESS POSITION. NEITHER SAID DOCUMENT NOR ITS
CONTENTS SHALL BE FURNISHED OR DISCLOSED TO OR COPIED OR USED BY PERSONS
OUTSIDE RAYTHEON COMPANY WITHOUT THE EXPRESS WRITTEN APPROVAL OF RAYTHEON
COMPANY.
THIS PROPRIETARY NOTICE IS NOT APPLICABLE IF DELIVERED TO THE U.S.
GOVERNMENT.
UNPUBLISHED WORK - COPYRIGHT RAYTHEON COMPANY.
-------------------------------------------------------------------------*/
#pragma once
#include "MessageIDs.hpp"
#include <vector>
class AutomationMsgHandler
{
public:
//>---------------------------------------------------------------------------
// Function: instance
//
// Purpose: singleton
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
static AutomationMsgHandler& instance();
//>---------------------------------------------------------------------------
// Function: ~Proc
//
// Purpose: Destroyer
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
~AutomationMsgHandler();
//>---------------------------------------------------------------------------
// Function: parseMsg
//
// Purpose:
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
void handleMsg(const unsigned char* pData, const unsigned int& id);
private:
//>---------------------------------------------------------------------------
// Function: AutomationMsgHandler
//
// Purpose: Ctor
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
AutomationMsgHandler();
//>---------------------------------------------------------------------------
// Function: HandleMoveGutsVideosToSubFolderMessage
//
// Purpose:
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
void handleAreYouThereMessage(const unsigned char* pData);
//>---------------------------------------------------------------------------
// Function: HandleKwScenarioStartedCMessage
//
// Purpose:
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
void handleKwScenarioStartedCMessage(const unsigned char* pData);
//>---------------------------------------------------------------------------
// Function: HandleKwScenarioStoppedCMessage
//
// Purpose:
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
void handleKwScenarioStoppedCMessage(const unsigned char* pData);
//>---------------------------------------------------------------------------
// Function: HandleWaitForLastTaskCompletionMessage
//
// Purpose:
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
void handleWaitForLastTaskCompletionMessage(const unsigned char* pData);
};

View File

@@ -0,0 +1,168 @@
#include <cerrno>
#include <cstdio>
#include <string.h>
#include <string>
#include <sstream>
#include <QByteArray>
#include <QString>
#include "AutomationMsgParser.hpp"
#include "Exception.hpp"
#include "MessageHeader.hpp"
#include "MessageIDs.hpp"
#include "ErrorLog.hpp"
#include "StringUtil.hpp"
//-----------------------------------------------------------------------------
AutomationMsgParser::AutomationMsgParser()
{
gatherCmdMessageIds();
}
//-----------------------------------------------------------------------------
AutomationMsgParser::~AutomationMsgParser(){}
//-----------------------------------------------------------------------------
AutomationMsgParser& AutomationMsgParser::instance()
{
static AutomationMsgParser parser;
return parser;
}
//-----------------------------------------------------------------------------
void AutomationMsgParser::gatherCmdMessageIds()
{
try {
msgIdsVec.push_back(MessageIDs::ARE_YOU_THERE_CMD);
msgIdsVec.push_back(MessageIDs::SCENARIO_STARTED_CMD);
msgIdsVec.push_back(MessageIDs::SCENARIO_STOPPED_CMD);
msgIdsVec.push_back(MessageIDs::WAIT_FOR_COMPLETION_CMD);
msgIdsVec.push_back(MessageIDs::GENERIC_RSP);
msgIdsVec.push_back(MessageIDs::ARE_YOU_THERE_RSP);
} catch (Exception& e) {
e.buildStackTrace(Q_FUNC_INFO);
throw e;
}
}
//-----------------------------------------------------------------------------
void AutomationMsgParser::parseMsg(unsigned char* pData, unsigned int numBytes, unsigned int* pMsgId)
{
bool selfThrown = false;
try
{
MessageHeader header;
if (numBytes < header.getHeaderLength())
{
std::stringstream ss;
ss << "Number of bytes received: " << numBytes << ". Expected minimum: " << header.getHeaderLength();
selfThrown = true;
throw Exception(Q_FUNC_INFO, ss.str());
}
// check to see if we recognize the header
unsigned int msgId = 0;
unsigned int msgLen = 0;
memcpy(&msgId, &pData[0], 4);
memcpy(&msgLen, &pData[4], 4);
if (std::find(msgIdsVec.begin(), msgIdsVec.end(), msgId) == msgIdsVec.end())
{
std::stringstream ss;
ss << "unexpected msg id: " << msgId;
selfThrown = true;
throw Exception(Q_FUNC_INFO, ss.str());
}
if ( msgLen != numBytes)
{
std::stringstream ss;
ss << "Number of bytes received: " << numBytes << ". Expected only: " << msgLen;
selfThrown = true;
throw Exception(Q_FUNC_INFO, ss.str());
}
if (numBytes > header.getHeaderLength())
verifyDataFormat(pData, numBytes);
*pMsgId = msgId;
}
catch (Exception& e)
{
if (!selfThrown)
e.buildStackTrace(Q_FUNC_INFO);
throw e;
}
}
//-----------------------------------------------------------------------------
void AutomationMsgParser::verifyDataFormat(unsigned char* pData, unsigned int numBytes)
{
MessageHeader header;
bool selfThrown = false;
unsigned char* pTempDataStart = pData + header.getHeaderLength();
unsigned char* pTempDataEnd = pData + numBytes - 1;
// data format is
// [data header - 4 bytes][data - variable size]
// [data header][data][data header][data][data header][data][data header][data]
const unsigned int DATA_HEADER_LENGTH = 4;
try {
std::stringstream ssError;
ssError << "Data structure is incorrect. Data: " << Util::Strings::ByteArrayToHexString(pData+header.getHeaderLength(), numBytes - header.getHeaderLength());
// want to make sure data size is at least 5 bytes
if (pTempDataStart+DATA_HEADER_LENGTH > pTempDataEnd)
{
selfThrown = true;
throw Exception(Q_FUNC_INFO, ssError.str());
}
while (pTempDataStart < pTempDataEnd)
{
unsigned int dataSize = *(reinterpret_cast<unsigned int*>(pTempDataStart));
if (dataSize == 0)
{
selfThrown = true;
throw Exception(Q_FUNC_INFO, ssError.str());
}
pTempDataStart += DATA_HEADER_LENGTH + dataSize;
if (pTempDataStart-1 > pTempDataEnd)
{
selfThrown = true;
throw Exception(Q_FUNC_INFO, ssError.str());
}
else if (pTempDataStart-1 == pTempDataEnd)
break;
}
}
catch (Exception& e)
{
if (!selfThrown)
e.buildStackTrace(Q_FUNC_INFO);
throw e;
}
}

View File

@@ -0,0 +1,94 @@
// UNCLASSIFIED
/*-------------------------------------------------------------------------
RAYTHEON PROPRIETARY: THIS DOCUMENT CONTAINS DATA OR INFORMATION
PROPRIETARY TO RAYTHEON COMPANY AND IS RESTRICTED TO USE ONLY BY PERSONS
AUTHORIZED BY RAYTHEON COMPANY IN WRITING TO USE IT. DISCLOSURE TO
UNAUTHORIZED PERSONS WOULD LIKELY CAUSE SUBSTANTIAL COMPETITIVE HARM TO
RAYTHEON COMPANY'S BUSINESS POSITION. NEITHER SAID DOCUMENT NOR ITS
CONTENTS SHALL BE FURNISHED OR DISCLOSED TO OR COPIED OR USED BY PERSONS
OUTSIDE RAYTHEON COMPANY WITHOUT THE EXPRESS WRITTEN APPROVAL OF RAYTHEON
COMPANY.
THIS PROPRIETARY NOTICE IS NOT APPLICABLE IF DELIVERED TO THE U.S.
GOVERNMENT.
UNPUBLISHED WORK - COPYRIGHT RAYTHEON COMPANY.
-------------------------------------------------------------------------*/
#pragma once
#include "MessageIDs.hpp"
#include <vector>
class AutomationMsgParser
{
public:
//>---------------------------------------------------------------------------
// Function: instance
//
// Purpose: singleton
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
static AutomationMsgParser& instance();
//>---------------------------------------------------------------------------
// Function: ~Proc
//
// Purpose: Destroyer
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
~AutomationMsgParser();
//>---------------------------------------------------------------------------
// Function: parseMsg
//
// Purpose:
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
void parseMsg(unsigned char* pData, unsigned int numBytes,unsigned int* pMsgId);
private:
//>---------------------------------------------------------------------------
// Function: AutomationMsgParser
//
// Purpose: Ctor
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
AutomationMsgParser();
//>---------------------------------------------------------------------------
// Function: gatherCmdMessageIds
//
// Purpose:
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
void gatherCmdMessageIds();
//>---------------------------------------------------------------------------
// Function: verifyDataFormat
//
// Purpose:
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
void verifyDataFormat(unsigned char* pData, unsigned int numBytes);
std::vector<MessageIDs::MsgIds> msgIdsVec;
};

View File

@@ -0,0 +1,103 @@
#include <sstream>
#include <string.h>
#include "GenericRspMessage.hpp"
#include "Exception.hpp"
//------------------------------------------------------------------------
GenericRspMessage::GenericRspMessage(const bool& wasCommandSuccessful):
Message(MessageIDs::GENERIC_RSP, "GENERIC_RSP", sizeof(MessageStruct)),
m_messageStruct()
{
m_messageStruct.wasCommandSuccessful = static_cast<unsigned int>(wasCommandSuccessful);
}
//------------------------------------------------------------------------
GenericRspMessage::GenericRspMessage(const GenericRspMessage& copy) :
Message(copy),
m_messageStruct(copy.m_messageStruct)
{
}
//------------------------------------------------------------------------
GenericRspMessage::~GenericRspMessage()
{
}
//------------------------------------------------------------------------
Message* GenericRspMessage::cloneSelf()
{
GenericRspMessage* pMsg = new GenericRspMessage(*this);
return pMsg;
}
//------------------------------------------------------------------------
void GenericRspMessage::executeMessage()
{
try
{
}
catch (Exception& e)
{
e.buildStackTrace(Q_FUNC_INFO);
throw e;
}
}
//------------------------------------------------------------------------
void GenericRspMessage::formatData(unsigned char* pData)
{
// Here's how the data is formatted
// each data item is preceded by a 4-byte header which tells us the size of the data item
// 1 data item will have [header][data]
// 2 data items will have [header][data][header][data]
unsigned int dataLen = 0;
const unsigned char* pTempDataStart = pData + getHeaderLength();
buildByteArray(&pTempDataStart, reinterpret_cast<char*>(&m_messageStruct.wasCommandSuccessful), sizeof(m_messageStruct.wasCommandSuccessful), dataLen);
// we want update total size of the entire message
m_header.setMessageLength(static_cast<unsigned short>(dataLen));
m_header.format(pData);
}
//------------------------------------------------------------------------
void GenericRspMessage::parseData(const unsigned char* pData)
{
bool selfThrown = false;
const unsigned char* pTempDataStart = pData;
const unsigned char* pTempDataEnd = pData + m_header.getMessageLength() - m_header.getHeaderLength() - 1;
std::stringstream ss;
int sizeOfData = 0;
try {
sizeOfData = getNextDataItem(&pTempDataStart, pTempDataEnd, sizeOfData);
// make sure byte number match between what we're expected and what we receive
compareByteNumber(sizeof(m_messageStruct.wasCommandSuccessful), sizeOfData);
memcpy(&m_messageStruct.wasCommandSuccessful, pTempDataStart, sizeOfData);
}
catch (Exception & e) {
if (!selfThrown)
e.buildStackTrace(Q_FUNC_INFO);
throw e;
}
}
//------------------------------------------------------------------------
std::string GenericRspMessage::toString() const
{
std::stringstream ss;
ss << Message::toString() << "wasCommandSuccessful: " << m_messageStruct.wasCommandSuccessful;
return ss.str();
}

View File

@@ -0,0 +1,138 @@
// UNCLASSIFIED
/*-------------------------------------------------------------------------
RAYTHEON PROPRIETARY: THIS DOCUMENT CONTAINS DATA OR INFORMATION
PROPRIETARY TO RAYTHEON COMPANY AND IS RESTRICTED TO USE ONLY BY PERSONS
AUTHORIZED BY RAYTHEON COMPANY IN WRITING TO USE IT. DISCLOSURE TO
UNAUTHORIZED PERSONS WOULD LIKELY CAUSE SUBSTANTIAL COMPETITIVE HARM TO
RAYTHEON COMPANY'S BUSINESS POSITION. NEITHER SAID DOCUMENT NOR ITS
CONTENTS SHALL BE FURNISHED OR DISCLOSED TO OR COPIED OR USED BY PERSONS
OUTSIDE RAYTHEON COMPANY WITHOUT THE EXPRESS WRITTEN APPROVAL OF RAYTHEON
COMPANY.
THIS PROPRIETARY NOTICE IS NOT APPLICABLE IF DELIVERED TO THE U.S.
GOVERNMENT.
UNPUBLISHED WORK - COPYRIGHT RAYTHEON COMPANY.
-------------------------------------------------------------------------*/
#pragma once
#include "Message.hpp"
#include "MessageIDs.hpp"
#include "MessageHeader.hpp"
class GenericRspMessage : public Message
{
public:
//>---------------------------------------------------------------------------
// Function: GenericRspMessage
//
// Purpose: constructor
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
GenericRspMessage(const bool& wasCommandSuccessful);
//>---------------------------------------------------------------------------
// Function: GenericRspMessage
//
// Purpose: copy constructor
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
GenericRspMessage(const GenericRspMessage &copy);
//>---------------------------------------------------------------------------
// Function: ~GenericRspMessage
//
// Purpose: destructor
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
virtual ~GenericRspMessage();
//>---------------------------------------------------------------------------
// Function: getSuccessfulFlag
//
// Purpose:
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
bool getSuccessfulFlag(){return static_cast<bool>(m_messageStruct.wasCommandSuccessful);}
//>---------------------------------------------------------------------------
// Function: executeMessage
//
// Purpose:
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
virtual void executeMessage();
//>---------------------------------------------------------------------------
// Function: toString
//
// Purpose:
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
virtual std::string toString() const;
protected:
//>---------------------------------------------------------------------------
// Function: cloneSelf
//
// Purpose:
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
virtual Message* cloneSelf();
//>---------------------------------------------------------------------------
// Function: formatData
//
// Purpose:
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
virtual void formatData(unsigned char* pData);
//>---------------------------------------------------------------------------
// Function: parseData
//
// Purpose:
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
virtual void parseData(const unsigned char* pData);
private:
// do not allow
GenericRspMessage &operator=(const GenericRspMessage &rhs);
#pragma pack(1)
struct MessageStruct
{
unsigned int wasCommandSuccessful;
};
#pragma pack()
MessageStruct m_messageStruct;
};

View File

@@ -0,0 +1,146 @@
#include <sstream>
#include <string>
#include "KwScenarioStartedMessage.hpp"
#include "Exception.hpp"
#include "FileSystemUtil.hpp"
#include "Util.hpp"
#include "LinuxProc.hpp"
#include "IniFile.hpp"
#include "GenericRspMessage.hpp"
#include "Condition.hpp"
#include "RunAppThread.hpp"
#include "MainWindow.h"
#include "UdpSocketMgr.hpp"
#include <QDir>
#include <QStringList>
#include <QDirIterator>
Thread* KwScenarioStartedMessage::ms_runAppThread = 0;
//------------------------------------------------------------------------
KwScenarioStartedMessage::KwScenarioStartedMessage():
Message(MessageIDs::SCENARIO_STARTED_CMD, "SCENARIO_STARTED_CMD")
{
}
//------------------------------------------------------------------------
KwScenarioStartedMessage::KwScenarioStartedMessage(const KwScenarioStartedMessage& copy) :
Message(copy)
{
}
//------------------------------------------------------------------------
KwScenarioStartedMessage::~KwScenarioStartedMessage()
{
}
//------------------------------------------------------------------------
Message* KwScenarioStartedMessage::cloneSelf()
{
KwScenarioStartedMessage* pMsg = new KwScenarioStartedMessage(*this);
return pMsg;
}
//------------------------------------------------------------------------
void KwScenarioStartedMessage::executeMessage()
{
try
{
Condition& commandExecutingEvent = LinuxProc::Instance().getEvent(EventNames::COMMAND_EXECUTTION_IN_PROGRESS);
Condition& completeEvent = LinuxProc::Instance().getEvent(EventNames::COMMAND_EXECUTION_COMPLETE);
completeEvent.reset();
if (commandExecutingEvent.timedWait(0,0)) // a command is current executing
{
completeEvent.wait(); // wait until current command finish executing
}
// signal this command is currently executing to prevent any other command from executing
commandExecutingEvent.signal();
GenericRspMessage rsp(true);
UdpSocketMgr::Instance().sendAMessage(rsp);
std::string appPath = "";
std::string threadName = "";
bool runApp = false;
if (LinuxProc::Instance().getComputerName() == Constants::ComputerHosts::SWDEV_PC)
{
threadName = "RunTelemetryThread";
appPath = LinuxProc::Instance().getConfig().getString(Constants::ConfigSectionNameMapping::sectionMap[LinuxProc::Instance().getComputerName()], "TELEMETRY_APP_PATH");
runApp = LinuxProc::Instance().getConfig().getBool(Constants::ConfigSectionNameMapping::sectionMap[LinuxProc::Instance().getComputerName()], "RUN_TELEMETRY");
}
else if (LinuxProc::Instance().getComputerName() == Constants::ComputerHosts::SIXDOF_PC)
{
threadName = "Run6DofThread";
appPath = LinuxProc::Instance().getConfig().getString(Constants::ConfigSectionNameMapping::sectionMap[LinuxProc::Instance().getComputerName()], "SIXDOF_APP_PATH");
runApp = LinuxProc::Instance().getConfig().getBool(Constants::ConfigSectionNameMapping::sectionMap[LinuxProc::Instance().getComputerName()], "RUN_SIXDOF");
}
if (appPath.length() > 0 && runApp)
{
if (Util::FileSystem::FileExists(appPath))
{
std::string appName = Util::FileSystem::ExtractFilename(appPath);
Util::KillProcess(appName);
}
if (ms_runAppThread == 0)
{
ms_runAppThread = new RunAppThread(threadName, appPath, true);
ms_runAppThread->create();
ms_runAppThread->resume();
}
ms_runAppThread->startThread();
}
commandExecutingEvent.reset();
completeEvent.signal();
}
catch (Exception& e)
{
e.buildStackTrace(Q_FUNC_INFO);
throw e;
}
}
//------------------------------------------------------------------------
void KwScenarioStartedMessage::formatData(unsigned char* pData)
{
// Here's how the data is formatted
// each data item is preceded by a 4-byte header which tells us the size of the data item
// 1 data item will have [header][data]
// 2 data items will have [header][data][header][data]
unsigned int dataLen = 0;
// we want update total size of the entire message
m_header.setMessageLength(static_cast<unsigned short>(dataLen));
m_header.format(pData);
}
//------------------------------------------------------------------------
void KwScenarioStartedMessage::parseData(const unsigned char*)
{
}
//------------------------------------------------------------------------
std::string KwScenarioStartedMessage::toString() const
{
std::stringstream ss;
ss << Message::toString() << ". No member data";
return ss.str();
}

View File

@@ -0,0 +1,134 @@
// UNCLASSIFIED
/*-------------------------------------------------------------------------
RAYTHEON PROPRIETARY: THIS DOCUMENT CONTAINS DATA OR INFORMATION
PROPRIETARY TO RAYTHEON COMPANY AND IS RESTRICTED TO USE ONLY BY PERSONS
AUTHORIZED BY RAYTHEON COMPANY IN WRITING TO USE IT. DISCLOSURE TO
UNAUTHORIZED PERSONS WOULD LIKELY CAUSE SUBSTANTIAL COMPETITIVE HARM TO
RAYTHEON COMPANY'S BUSINESS POSITION. NEITHER SAID DOCUMENT NOR ITS
CONTENTS SHALL BE FURNISHED OR DISCLOSED TO OR COPIED OR USED BY PERSONS
OUTSIDE RAYTHEON COMPANY WITHOUT THE EXPRESS WRITTEN APPROVAL OF RAYTHEON
COMPANY.
THIS PROPRIETARY NOTICE IS NOT APPLICABLE IF DELIVERED TO THE U.S.
GOVERNMENT.
UNPUBLISHED WORK - COPYRIGHT RAYTHEON COMPANY.
-------------------------------------------------------------------------*/
#pragma once
#include "Message.hpp"
#include "MessageIDs.hpp"
#include "MessageHeader.hpp"
class Thread;
class KwScenarioStartedMessage : public Message
{
public:
//>---------------------------------------------------------------------------
// Function: KwScenarioStarted
//
// Purpose: constructor
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
KwScenarioStartedMessage();
//>---------------------------------------------------------------------------
// Function: KwScenarioStarted
//
// Purpose: copy constructor
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
KwScenarioStartedMessage(const KwScenarioStartedMessage &copy);
//>---------------------------------------------------------------------------
// Function: ~KwScenarioStarted
//
// Purpose: destructor
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
virtual ~KwScenarioStartedMessage();
//>---------------------------------------------------------------------------
// Function: ExecuteMessage
//
// Purpose:
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
virtual void executeMessage();
//>---------------------------------------------------------------------------
// Function: ToString
//
// Purpose:
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
virtual std::string toString() const;
//>---------------------------------------------------------------------------
// Function: getRunAppThread
//
// Purpose:
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
static Thread* getRunAppThread(){return ms_runAppThread;}
protected:
//>---------------------------------------------------------------------------
// Function: CloneSelf
//
// Purpose:
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
virtual Message* cloneSelf();
//>---------------------------------------------------------------------------
// Function: FormatData
//
// Purpose:
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
virtual void formatData(unsigned char* pData);
//>---------------------------------------------------------------------------
// Function: ParseData
//
// Purpose:
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
virtual void parseData(const unsigned char*);
private:
// do not allow
KwScenarioStartedMessage &operator=(const KwScenarioStartedMessage &rhs);
static Thread* ms_runAppThread;
};

View File

@@ -0,0 +1,208 @@
#include <sstream>
#include <string.h>
#include "KwScenarioStoppedMessage.hpp"
#include "Exception.hpp"
#include "StringUtil.hpp"
#include "Util.hpp"
#include "FileSystemUtil.hpp"
#include "LinuxProc.hpp"
#include "IniFile.hpp"
#include "GenericRspMessage.hpp"
#include "Condition.hpp"
#include "MainWindow.h"
#include "UdpSocketMgr.hpp"
#include "ConfigFileManager.hpp"
#include "FileTransferThread.hpp"
#include <QDir>
#include <QStringList>
#include <QDirIterator>
#include <QRegularExpression>
//------------------------------------------------------------------------
KwScenarioStoppedMessage::KwScenarioStoppedMessage():
Message(MessageIDs::SCENARIO_STOPPED_CMD, "SCENARIO_STOPPED_CMD")
{
}
//------------------------------------------------------------------------
KwScenarioStoppedMessage::KwScenarioStoppedMessage(const KwScenarioStoppedMessage& copy) :
Message(copy)
{
}
//------------------------------------------------------------------------
KwScenarioStoppedMessage::~KwScenarioStoppedMessage()
{
}
//------------------------------------------------------------------------
Message* KwScenarioStoppedMessage::cloneSelf()
{
KwScenarioStoppedMessage* pMsg = new KwScenarioStoppedMessage(*this);
return pMsg;
}
//------------------------------------------------------------------------
void KwScenarioStoppedMessage::executeMessage()
{
try
{
Condition& commandExecutingEvent = LinuxProc::Instance().getEvent(EventNames::COMMAND_EXECUTTION_IN_PROGRESS);
Condition& completeEvent = LinuxProc::Instance().getEvent(EventNames::COMMAND_EXECUTION_COMPLETE);
completeEvent.reset();
if (commandExecutingEvent.timedWait(0,0)) // a command is current executing
{
completeEvent.wait(); // wait until current command finish executing
}
// signal this command is currently executing to prevent any other command from executing
commandExecutingEvent.signal();
GenericRspMessage rsp(true);
UdpSocketMgr::Instance().sendAMessage(rsp);
std::string appPath = "";
if (LinuxProc::Instance().getComputerName() == Constants::ComputerHosts::SWDEV_PC)
{
appPath = LinuxProc::Instance().getConfig().getString(Constants::ConfigSectionNameMapping::sectionMap[LinuxProc::Instance().getComputerName()], "TELEMETRY_APP_PATH");
}
else if (LinuxProc::Instance().getComputerName() == Constants::ComputerHosts::SIXDOF_PC)
{
appPath = LinuxProc::Instance().getConfig().getString(Constants::ConfigSectionNameMapping::sectionMap[LinuxProc::Instance().getComputerName()], "SIXDOF_APP_PATH");
}
else if ((LinuxProc::Instance().getComputerName() == Constants::ComputerHosts::VIDEO_PC))
{
}
if (appPath.length() > 0)
{
if (Util::FileSystem::FileExists(appPath))
{
std::string appName = Util::FileSystem::ExtractFilename(appPath);
Util::KillProcess(appName);
}
}
if (gatherTestDataAndLogs())
{
m_testDataPath = Util::FileSystem::BuildPath(LinuxProc::Instance().getConfig().getString("GENERAL", "BASE_TEST_DATA_PATH"),m_testDataPath);
LinuxProc::Instance().getFileTransferThread()->setDestDir(m_testDataPath);
Condition& event = LinuxProc::Instance().getEvent(EventNames::START_FILE_TRANSFER);
event.signal();
}
commandExecutingEvent.reset();
completeEvent.signal();
}
catch (Exception& e)
{
e.buildStackTrace(Q_FUNC_INFO);
throw e;
}
}
//------------------------------------------------------------------------
bool KwScenarioStoppedMessage::gatherTestDataAndLogs()
{
bool success = false;
std::vector<std::string> filesToBeTransferred;
std::map<std::string, ConfigFileManager::TestDataInfo, CustomDataTypes::ci_less> testDataMap = ConfigFileManager::Instance().getTestDataMap();
std::map<std::string, ConfigFileManager::TestDataInfo, CustomDataTypes::ci_less>::iterator it;
std::vector<std::string>::iterator it2;
int fileCreatedMinutesAgo = 5;
for (it = testDataMap.begin(); it != testDataMap.end(); it++)
{
std::vector<std::string> regexPatternVec = Util::Strings::StringSplit(it->second.fileRegexPatterns, ",", false);
QDir sourceDir(it->second.path.c_str());
QStringList tempList = Util::FileSystem::GetListOfFilesInADirectory(sourceDir, false);
for ( int i = 0; i < tempList.size(); i++ )
{
for (it2 = regexPatternVec.begin(); it2 != regexPatternVec.end(); it2++)
{
std::string regexPattern = Util::Strings::TrimSpaces(*it2);
QRegularExpression re(regexPattern.c_str(), QRegularExpression::CaseInsensitiveOption);
QRegularExpressionMatch match = re.match(tempList[i]);
if (match.hasMatch())
{
QFileInfo fi(tempList[i]);
if (fi.lastModified().secsTo(QDateTime::currentDateTime()) <= fileCreatedMinutesAgo * 60)
{
LinuxProc::Instance().getFileTransferThread()->addSourceFile(tempList[i].toStdString());
if (!success)
success = true;
break;
}
}
}
}
}
return success;
}
//------------------------------------------------------------------------
void KwScenarioStoppedMessage::formatData(unsigned char* pData)
{
// Here's how the data is formatted
// each data item is preceded by a 4-byte header which tells us the size of the data item
// 1 data item will have [header][data]
// 2 data items will have [header][data][header][data]
unsigned int dataLen = 0;
const unsigned char* pTempDataStart = pData + getHeaderLength();
buildByteArray(&pTempDataStart, m_testDataPath.c_str(), m_testDataPath.length(), dataLen);
// we want update total size of the entire message
m_header.setMessageLength(static_cast<unsigned short>(dataLen));
m_header.format(pData);
}
//------------------------------------------------------------------------
void KwScenarioStoppedMessage::parseData(const unsigned char* pData)
{
const unsigned char* pTempDataStart = pData;
const unsigned char* pTempDataEnd = pData + m_header.getMessageLength() - m_header.getHeaderLength() - 1;
int sizeOfData = 0;
try {
sizeOfData = getNextDataItem(&pTempDataStart, pTempDataEnd, sizeOfData);
m_testDataPath = Util::Strings::ByteArrayToString(const_cast<unsigned char*>(pTempDataStart), sizeOfData);
}
catch (Exception& e) {
e.buildStackTrace(Q_FUNC_INFO);
throw e;
}
}
//------------------------------------------------------------------------
std::string KwScenarioStoppedMessage::toString() const
{
std::stringstream ss;
ss << Message::toString() << ". testDataPath: " << m_testDataPath;
return ss.str();
}

View File

@@ -0,0 +1,132 @@
// UNCLASSIFIED
/*-------------------------------------------------------------------------
RAYTHEON PROPRIETARY: THIS DOCUMENT CONTAINS DATA OR INFORMATION
PROPRIETARY TO RAYTHEON COMPANY AND IS RESTRICTED TO USE ONLY BY PERSONS
AUTHORIZED BY RAYTHEON COMPANY IN WRITING TO USE IT. DISCLOSURE TO
UNAUTHORIZED PERSONS WOULD LIKELY CAUSE SUBSTANTIAL COMPETITIVE HARM TO
RAYTHEON COMPANY'S BUSINESS POSITION. NEITHER SAID DOCUMENT NOR ITS
CONTENTS SHALL BE FURNISHED OR DISCLOSED TO OR COPIED OR USED BY PERSONS
OUTSIDE RAYTHEON COMPANY WITHOUT THE EXPRESS WRITTEN APPROVAL OF RAYTHEON
COMPANY.
THIS PROPRIETARY NOTICE IS NOT APPLICABLE IF DELIVERED TO THE U.S.
GOVERNMENT.
UNPUBLISHED WORK - COPYRIGHT RAYTHEON COMPANY.
-------------------------------------------------------------------------*/
#pragma once
#include "Message.hpp"
#include "MessageIDs.hpp"
#include "MessageHeader.hpp"
class KwScenarioStoppedMessage : public Message
{
public:
//>---------------------------------------------------------------------------
// Function: KwScenarioStopped
//
// Purpose: constructor
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
KwScenarioStoppedMessage();
//>---------------------------------------------------------------------------
// Function: KwScenarioStopped
//
// Purpose: copy constructor
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
KwScenarioStoppedMessage(const KwScenarioStoppedMessage &copy);
//>---------------------------------------------------------------------------
// Function: ~KwScenarioStopped
//
// Purpose: destructor
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
virtual ~KwScenarioStoppedMessage();
//>---------------------------------------------------------------------------
// Function: ExecuteMessage
//
// Purpose:
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
virtual void executeMessage();
//>---------------------------------------------------------------------------
// Function: ToString
//
// Purpose:
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
virtual std::string toString() const;
protected:
//>---------------------------------------------------------------------------
// Function: CloneSelf
//
// Purpose:
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
virtual Message* cloneSelf();
//>---------------------------------------------------------------------------
// Function: FormatData
//
// Purpose:
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
virtual void formatData(unsigned char* pData);
//>---------------------------------------------------------------------------
// Function: ParseData
//
// Purpose:
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
virtual void parseData(const unsigned char*);
private:
// do not allow
KwScenarioStoppedMessage &operator=(const KwScenarioStoppedMessage &rhs);
//>---------------------------------------------------------------------------
// Function: gatherTestDataAndLogs
//
// Purpose:
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
bool gatherTestDataAndLogs();
std::string m_testDataPath;
};

View File

@@ -0,0 +1,175 @@
#include <sstream>
#include "Message.hpp"
#include "Exception.hpp"
#include "StringUtil.hpp"
//------------------------------------------------------------------------
Message::Message(const MessageIDs::MsgIds& id,
const std::string& description,
const unsigned short& messageLen) :
m_header(id, messageLen),
m_description(description)
{
}
//------------------------------------------------------------------------
Message::Message(const Message& copy) :
m_header(copy.m_header),
m_description(copy.m_description)
{
}
//------------------------------------------------------------------------
Message::~Message()
{
}
//------------------------------------------------------------------------
Message* Message::clone()
{
return cloneSelf();
}
//------------------------------------------------------------------------
void Message::format(unsigned char* pBuffer)
{
try
{
m_header.format(pBuffer);
formatData(pBuffer);
}
catch (Exception& e)
{
e.buildStackTrace(Q_FUNC_INFO);
throw e;
}
}
//------------------------------------------------------------------------
std::string Message::getDescription() const
{
return m_description;
}
//------------------------------------------------------------------------
void Message::parse(const unsigned char* pData)
{
try
{
m_header.parse(pData);
parseData(pData + getHeaderLength());
}
catch (Exception& e)
{
e.buildStackTrace(Q_FUNC_INFO);
throw e;
}
}
//------------------------------------------------------------------------
void Message::setMessageLength(const unsigned short& length)
{
m_header.setMessageLength(length);
}
//------------------------------------------------------------------------
std::string Message::toString() const
{
std::stringstream ss;
ss << "Message: " << getDescription() << ". " << m_header.toString();
return ss.str();
}
//------------------------------------------------------------------------
int Message::getNextDataItem(const unsigned char** pStartBuf, const unsigned char* pEndBuf, int& sizeOfPreviousData)
{
bool selfThrown = false;
int sizeOfDataHeader = 4;
int sizeOfData = 0;
std::stringstream ssError;
*pStartBuf += sizeOfPreviousData;
ssError << "Data structure is incorrect. Data: " << Util::Strings::ByteArrayToHexString(const_cast<unsigned char*>(*pStartBuf), pEndBuf - *pStartBuf + 1);
try {
// make sure 4 bytes of header information is present
if (*pStartBuf + sizeOfDataHeader > pEndBuf)
{
selfThrown = true;
throw Exception(Q_FUNC_INFO, ssError.str());
}
sizeOfData = *(*pStartBuf);
// we want to make sure the nth header and nth data information match
// header tells us how many bytes in the nth data item, and the bytes
// of data is present in the buffer
if (*pStartBuf + sizeOfDataHeader + sizeOfData -1 <= pEndBuf)
{
// points to the address of the nth data item
*pStartBuf += sizeOfDataHeader;
}
else
{
selfThrown = true;
throw Exception(Q_FUNC_INFO, ssError.str());
}
} catch (Exception& e) {
if (!selfThrown)
e.buildStackTrace(Q_FUNC_INFO);
throw e;
}
return sizeOfData;
}
//------------------------------------------------------------------------
void Message::buildByteArray(const unsigned char** pStartBuf, const char* data, const int& sizeOfDataBytes, unsigned int& totalBytesInArray)
{
// copy the header information for this data item
memcpy(const_cast<unsigned char*>(*pStartBuf), &sizeOfDataBytes, sizeof(sizeOfDataBytes));
*pStartBuf += sizeof(sizeOfDataBytes);
totalBytesInArray += sizeof(sizeOfDataBytes);
// copy the data for this data item
memcpy(const_cast<unsigned char*>(*pStartBuf), data, sizeOfDataBytes);
*pStartBuf += sizeOfDataBytes;
totalBytesInArray += sizeOfDataBytes;
}
//------------------------------------------------------------------------
void Message::compareByteNumber(int expectedNumBytes, int actualNumbyte)
{
bool selfThrown = false;
std::stringstream ss;
try
{
if (expectedNumBytes != actualNumbyte)
{
selfThrown = true;
ss << "Expected number of bytes received: " << expectedNumBytes << ". Actual number of bytes received: " << actualNumbyte;
throw Exception(Q_FUNC_INFO, ss.str());
}
}
catch (Exception & e) {
if (!selfThrown)
e.buildStackTrace(Q_FUNC_INFO);
throw e;
}
}

View File

@@ -0,0 +1,257 @@
// UNCLASSIFIED
/*-------------------------------------------------------------------------
RAYTHEON PROPRIETARY: THIS DOCUMENT CONTAINS DATA OR INFORMATION
PROPRIETARY TO RAYTHEON COMPANY AND IS RESTRICTED TO USE ONLY BY PERSONS
AUTHORIZED BY RAYTHEON COMPANY IN WRITING TO USE IT. DISCLOSURE TO
UNAUTHORIZED PERSONS WOULD LIKELY CAUSE SUBSTANTIAL COMPETITIVE HARM TO
RAYTHEON COMPANY'S BUSINESS POSITION. NEITHER SAID DOCUMENT NOR ITS
CONTENTS SHALL BE FURNISHED OR DISCLOSED TO OR COPIED OR USED BY PERSONS
OUTSIDE RAYTHEON COMPANY WITHOUT THE EXPRESS WRITTEN APPROVAL OF RAYTHEON
COMPANY.
THIS PROPRIETARY NOTICE IS NOT APPLICABLE IF DELIVERED TO THE U.S.
GOVERNMENT.
UNPUBLISHED WORK - COPYRIGHT RAYTHEON COMPANY.
-------------------------------------------------------------------------*/
#pragma once
#include <iostream>
#include "MessageIDs.hpp"
#include "MessageHeader.hpp"
class Message
{
public:
//>---------------------------------------------------------------------
// Function: ~Message()
//
// Purpose: destructor
//----------------------------------------------------------------------
// Arguments: none
//----------------------------------------------------------------------
// Return Value: none
//<---------------------------------------------------------------------
virtual ~Message();
//>---------------------------------------------------------------------
// Function: Clone()
//
// Purpose: Get a copy of this object
//----------------------------------------------------------------------
// Arguments: none
//----------------------------------------------------------------------
// Return Value: a copy of this object
//<---------------------------------------------------------------------
virtual Message* clone();
//>---------------------------------------------------------------------
// Function: ExecuteMessage()
//
// Purpose: Executes this message
//----------------------------------------------------------------------
// Arguments: none
//----------------------------------------------------------------------
// Return Value: none
//<---------------------------------------------------------------------
virtual void executeMessage() = 0;
//>---------------------------------------------------------------------
// Function: Format()
//
// Purpose: Formats this message for sending
//----------------------------------------------------------------------
// Arguments: pBuffer - the buffer to put the formatting data in
//----------------------------------------------------------------------
// Return Value: none
//<---------------------------------------------------------------------
virtual void format(unsigned char* pBuffer);
//>---------------------------------------------------------------------
// Function: GetDescription()
//
// Purpose: Getter for this objects description
//----------------------------------------------------------------------
// Arguments: none
//----------------------------------------------------------------------
// Return Value: The description
//<---------------------------------------------------------------------
virtual std::string getDescription() const;
//>---------------------------------------------------------------------
// Function: GetMessageID()
//
// Purpose: Getter for this objects message id
//----------------------------------------------------------------------
// Arguments: none
//----------------------------------------------------------------------
// Return Value: The id
//<---------------------------------------------------------------------
virtual MessageIDs::MsgIds getMessageID() { return m_header.getMessageId(); }
//>---------------------------------------------------------------------
// Function: GetEntireMessageLength()
//
// Purpose: Getter for this objects message number of bytes, including the header
//----------------------------------------------------------------------
// Arguments: none
//----------------------------------------------------------------------
// Return Value: The entire message number of bytes
//<---------------------------------------------------------------------
virtual unsigned int getEntireMessageLength() const { return m_header.getMessageLength();}
//>---------------------------------------------------------------------
// Function: GetHeaderLength()
//
// Purpose: Getter for this objects message number of header bytes
//----------------------------------------------------------------------
// Arguments: none
//----------------------------------------------------------------------
// Return Value: The header number of bytes
//<---------------------------------------------------------------------
virtual unsigned short getHeaderLength() const { return m_header.getHeaderLength();}
//>---------------------------------------------------------------------
// Function: Parse()
//
// Purpose: Takes an array of bytes and populates this object
//----------------------------------------------------------------------
// Arguments: The array of bytes
//----------------------------------------------------------------------
// Return Value: None
//<---------------------------------------------------------------------
virtual void parse(const unsigned char* pData);
//>---------------------------------------------------------------------
// Function: ToString()
//
// Purpose: Converts this object into a string
//----------------------------------------------------------------------
// Arguments: None
//----------------------------------------------------------------------
// Return Value: The string form of this object
//<---------------------------------------------------------------------
virtual std::string toString() const;
protected:
//>---------------------------------------------------------------------
// Function: Constructor
//
// Purpose: The constructor for the childern to call
//----------------------------------------------------------------------
// Arguments: id - the message id
// description - the message description
// messageLen - the number of bytes in the message payload (not including the header)
//----------------------------------------------------------------------
// Return Value: The object
//<---------------------------------------------------------------------
Message(const MessageIDs::MsgIds& id,
const std::string& description,
const unsigned short& messageLen = 0);
//>---------------------------------------------------------------------
// Function: Copy Constructor
//
// Purpose: Create a copy of this object
//----------------------------------------------------------------------
// Arguments: copy - the object to copy
//----------------------------------------------------------------------
// Return Value: The object
//<---------------------------------------------------------------------
Message(const Message &copy);
//>---------------------------------------------------------------------
// Function: CloneSelf
//
// Purpose: Pure virtual function for children to implement.
// Create a clone of this object
//----------------------------------------------------------------------
// Arguments: none
//----------------------------------------------------------------------
// Return Value: The object
//<---------------------------------------------------------------------
virtual Message* cloneSelf() = 0;
//>---------------------------------------------------------------------
// Function: FormatData
//
// Purpose: Pure virtual function for children to implement.
// Format the data
//----------------------------------------------------------------------
// Arguments: pData - the buffer to format to
//----------------------------------------------------------------------
// Return Value: none
//<---------------------------------------------------------------------
virtual void formatData(unsigned char* pData) = 0;
//>---------------------------------------------------------------------
// Function: ParseData
//
// Purpose: Pure virtual function for children to implement.
// Parse the data
//----------------------------------------------------------------------
// Arguments: pData - the buffer to parse from
//----------------------------------------------------------------------
// Return Value: none
//<---------------------------------------------------------------------
virtual void parseData(const unsigned char* pData) = 0;
//>---------------------------------------------------------------------
// Function: SetMessageLength
//
// Purpose: Sets the message length of the payload of the message (not the header)
//----------------------------------------------------------------------
// Arguments: length - the number of bytes in the payload
//----------------------------------------------------------------------
// Return Value: none
//<---------------------------------------------------------------------
virtual void setMessageLength(const unsigned short& length);
//>---------------------------------------------------------------------
// Function: getNextDataItem
//
// Purpose:
// get the next data item
// data format:
// [data header][data][data header][data]...
//----------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------
// Return Value: none
//<---------------------------------------------------------------------
int getNextDataItem(const unsigned char** pStartBuf, const unsigned char* pEndBuf, int& sizeOfPreviousData);
//>---------------------------------------------------------------------
// Function: buildByteArray
//
// Purpose:
// this will add to the byte array a data item
// data format:
// [data header][data]
//----------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------
// Return Value: none
//<---------------------------------------------------------------------
void buildByteArray(const unsigned char** pStartBuf, const char* data, const int& sizeOfDataBytes, unsigned int& totalBytesInArray);
//>---------------------------------------------------------------------
// Function: compareByteNumber
//
// Purpose:
//----------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------
// Return Value: none
//<---------------------------------------------------------------------
void compareByteNumber(int expectedNumBytes, int actualNumbyte);
MessageHeader m_header;
private:
// do not allow
Message();
Message &operator=(const Message &rhs);
std::string m_description;
};

View File

@@ -0,0 +1,86 @@
#include <sstream>
#include <string.h>
#include "MessageHeader.hpp"
//------------------------------------------------------------------------
MessageHeader::MessageHeader(const MessageIDs::MsgIds& id, const unsigned short& messageLen) :
m_headerStruct()
{
m_headerStruct.messageId = id;
m_headerStruct.messageLength = messageLen + getHeaderLength();
}
//------------------------------------------------------------------------
MessageHeader::MessageHeader() :
m_headerStruct()
{
m_headerStruct.messageId = 0;
m_headerStruct.messageLength = 0;
}
//------------------------------------------------------------------------
MessageHeader::MessageHeader(const MessageHeader& copy) :
m_headerStruct(copy.m_headerStruct)
{
}
//------------------------------------------------------------------------
MessageHeader::~MessageHeader()
{
}
//------------------------------------------------------------------------
void MessageHeader::format(unsigned char* pData)
{
memcpy(pData, &m_headerStruct, getHeaderLength());
}
//------------------------------------------------------------------------
MessageIDs::MsgIds MessageHeader::getMessageId()
{
return (MessageIDs::MsgIds)m_headerStruct.messageId;
}
//------------------------------------------------------------------------
unsigned short MessageHeader::getHeaderLength() const
{
return sizeof(m_headerStruct);
}
//------------------------------------------------------------------------
unsigned int MessageHeader::getMessageLength() const
{
return m_headerStruct.messageLength;
}
//------------------------------------------------------------------------
void MessageHeader::parse(const unsigned char* pData)
{
::memcpy(&m_headerStruct, pData, getHeaderLength());
}
//------------------------------------------------------------------------
void MessageHeader::setMessageLength(const unsigned short& length)
{
m_headerStruct.messageLength = length + getHeaderLength();
}
//------------------------------------------------------------------------
std::string MessageHeader::toString() const
{
std::stringstream ss;
ss << "msg id: 0x" << std::hex << std::uppercase << m_headerStruct.messageId << std::nouppercase << ". " << "msg len: " << std::dec << m_headerStruct.messageLength;
return ss.str();
}

View File

@@ -0,0 +1,163 @@
// UNCLASSIFIED
/*-------------------------------------------------------------------------
RAYTHEON PROPRIETARY: THIS DOCUMENT CONTAINS DATA OR INFORMATION
PROPRIETARY TO RAYTHEON COMPANY AND IS RESTRICTED TO USE ONLY BY PERSONS
AUTHORIZED BY RAYTHEON COMPANY IN WRITING TO USE IT. DISCLOSURE TO
UNAUTHORIZED PERSONS WOULD LIKELY CAUSE SUBSTANTIAL COMPETITIVE HARM TO
RAYTHEON COMPANY'S BUSINESS POSITION. NEITHER SAID DOCUMENT NOR ITS
CONTENTS SHALL BE FURNISHED OR DISCLOSED TO OR COPIED OR USED BY PERSONS
OUTSIDE RAYTHEON COMPANY WITHOUT THE EXPRESS WRITTEN APPROVAL OF RAYTHEON
COMPANY.
THIS PROPRIETARY NOTICE IS NOT APPLICABLE IF DELIVERED TO THE U.S.
GOVERNMENT.
UNPUBLISHED WORK - COPYRIGHT RAYTHEON COMPANY.
-------------------------------------------------------------------------*/
#pragma once
#include <string>
#include "MessageIDs.hpp"
class MessageHeader
{
public:
//>---------------------------------------------------------------------
// Function: MessageHeader
//
// Purpose: constructor
//----------------------------------------------------------------------
// Arguments: id - the message id
// messageLen - the number of bytes of the entire message including the header
//----------------------------------------------------------------------
// Return Value: none
//<---------------------------------------------------------------------
MessageHeader(const MessageIDs::MsgIds& id, const unsigned short& messageLen);
//>---------------------------------------------------------------------
// Function: MessageHeader
//
// Purpose: constructor
//----------------------------------------------------------------------
// Arguments: none
//----------------------------------------------------------------------
// Return Value: none
//<---------------------------------------------------------------------
MessageHeader();
//>---------------------------------------------------------------------
// Function: Copy Constructor
//
// Purpose: Create a copy of this object
//----------------------------------------------------------------------
// Arguments: copy - the object to copy
//----------------------------------------------------------------------
// Return Value: The object
//<---------------------------------------------------------------------
MessageHeader(const MessageHeader &copy);
//>---------------------------------------------------------------------
// Function: ~MessageHeader()
//
// Purpose: destructor
//----------------------------------------------------------------------
// Arguments: none
//----------------------------------------------------------------------
// Return Value: none
//<---------------------------------------------------------------------
virtual ~MessageHeader();
//>---------------------------------------------------------------------
// Function: Format()
//
// Purpose: Formats this message for sending
//----------------------------------------------------------------------
// Arguments: pBuffer - the buffer to put the formatting data in
//----------------------------------------------------------------------
// Return Value: none
//<---------------------------------------------------------------------
void format(unsigned char* pData);
//>---------------------------------------------------------------------
// Function: GetHeaderLength()
//
// Purpose: Get the number of bytes in the header
//----------------------------------------------------------------------
// Arguments: none
//----------------------------------------------------------------------
// Return Value: number of bytes in the header
//<---------------------------------------------------------------------
unsigned short getHeaderLength() const;
//>---------------------------------------------------------------------
// Function: GetMessageLength()
//
// Purpose: Get the number of bytes in the entire message, including header
//----------------------------------------------------------------------
// Arguments: none
//----------------------------------------------------------------------
// Return Value: number of bytes in the message
//<---------------------------------------------------------------------
unsigned int getMessageLength() const;
//>---------------------------------------------------------------------
// Function: GetMessageId()
//
// Purpose: Get the message id
//----------------------------------------------------------------------
// Arguments: none
//----------------------------------------------------------------------
// Return Value: the message id
//<---------------------------------------------------------------------
MessageIDs::MsgIds getMessageId();
//>---------------------------------------------------------------------
// Function: Parse()
//
// Purpose: Takes an array of bytes and populates this object
//----------------------------------------------------------------------
// Arguments: The array of bytes
//----------------------------------------------------------------------
// Return Value: None
//<---------------------------------------------------------------------
void parse(const unsigned char* pData);
//>---------------------------------------------------------------------
// Function: SetMessageLength
//
// Purpose: Sets the message length of the payload of the message (not the header)
//----------------------------------------------------------------------
// Arguments: length - the number of bytes in the payload
//----------------------------------------------------------------------
// Return Value: none
//<---------------------------------------------------------------------
void setMessageLength(const unsigned short& length);
//>---------------------------------------------------------------------
// Function: ToString()
//
// Purpose: Converts this object into a string
//----------------------------------------------------------------------
// Arguments: None
//----------------------------------------------------------------------
// Return Value: The string form of this object
//<---------------------------------------------------------------------
std::string toString() const;
protected:
private:
// do not allow
MessageHeader &operator=(const MessageHeader &rhs);
#pragma pack(1)
struct HeaderStruct
{
unsigned int messageId;
unsigned int messageLength;
};
#pragma pack()
HeaderStruct m_headerStruct;
};

View File

@@ -0,0 +1,33 @@
// UNCLASSIFIED
/*-------------------------------------------------------------------------
RAYTHEON PROPRIETARY: THIS DOCUMENT CONTAINS DATA OR INFORMATION
PROPRIETARY TO RAYTHEON COMPANY AND IS RESTRICTED TO USE ONLY BY PERSONS
AUTHORIZED BY RAYTHEON COMPANY IN WRITING TO USE IT. DISCLOSURE TO
UNAUTHORIZED PERSONS WOULD LIKELY CAUSE SUBSTANTIAL COMPETITIVE HARM TO
RAYTHEON COMPANY'S BUSINESS POSITION. NEITHER SAID DOCUMENT NOR ITS
CONTENTS SHALL BE FURNISHED OR DISCLOSED TO OR COPIED OR USED BY PERSONS
OUTSIDE RAYTHEON COMPANY WITHOUT THE EXPRESS WRITTEN APPROVAL OF RAYTHEON
COMPANY.
THIS PROPRIETARY NOTICE IS NOT APPLICABLE IF DELIVERED TO THE U.S.
GOVERNMENT.
UNPUBLISHED WORK - COPYRIGHT RAYTHEON COMPANY.
-------------------------------------------------------------------------*/
#pragma once
namespace MessageIDs
{
enum MsgIds
{
ARE_YOU_THERE_CMD = 0xCA001004,
SCENARIO_STARTED_CMD = 0xCA001005,
SCENARIO_STOPPED_CMD = 0xCA001006,
WAIT_FOR_COMPLETION_CMD = 0xCA002000,
GENERIC_RSP = 0xCA002001,
ARE_YOU_THERE_RSP = 0xCA002002
};
}

View File

@@ -0,0 +1,83 @@
#include <sstream>
#include <string.h>
#include "WaitForLastTaskCompletionCmdMessage.hpp"
#include "Exception.hpp"
#include "Condition.hpp"
#include "LinuxProc.hpp"
#include "GenericRspMessage.hpp"
#include "UdpSocketMgr.hpp"
bool WaitForLastTaskCompletionCmdMessage::s_commandCompletionSuccess = true;
//------------------------------------------------------------------------
WaitForLastTaskCompletionCmdMessage::WaitForLastTaskCompletionCmdMessage():
Message(MessageIDs::WAIT_FOR_COMPLETION_CMD, "WAIT_FOR_COMPLETION_CMD")
{
}
//------------------------------------------------------------------------
WaitForLastTaskCompletionCmdMessage::WaitForLastTaskCompletionCmdMessage(const WaitForLastTaskCompletionCmdMessage& copy) :
Message(copy)
{
}
//------------------------------------------------------------------------
WaitForLastTaskCompletionCmdMessage::~WaitForLastTaskCompletionCmdMessage()
{
}
//------------------------------------------------------------------------
Message* WaitForLastTaskCompletionCmdMessage::cloneSelf()
{
WaitForLastTaskCompletionCmdMessage* pMsg = new WaitForLastTaskCompletionCmdMessage(*this);
return pMsg;
}
//------------------------------------------------------------------------
void WaitForLastTaskCompletionCmdMessage::executeMessage()
{
try
{
Condition& event = LinuxProc::Instance().getEvent(EventNames::COMMAND_EXECUTION_COMPLETE);
event.wait(false);
GenericRspMessage rsp(s_commandCompletionSuccess);
UdpSocketMgr::Instance().sendAMessage(rsp);
}
catch (Exception& e)
{
e.buildStackTrace(Q_FUNC_INFO);
throw e;
}
}
//------------------------------------------------------------------------
void WaitForLastTaskCompletionCmdMessage::formatData(unsigned char*)
{
// no data to send
}
//------------------------------------------------------------------------
void WaitForLastTaskCompletionCmdMessage::parseData(const unsigned char*)
{
// no data to process
}
//------------------------------------------------------------------------
std::string WaitForLastTaskCompletionCmdMessage::toString() const
{
std::stringstream ss;
ss << "";
return ss.str();
}

View File

@@ -0,0 +1,121 @@
// UNCLASSIFIED
/*-------------------------------------------------------------------------
RAYTHEON PROPRIETARY: THIS DOCUMENT CONTAINS DATA OR INFORMATION
PROPRIETARY TO RAYTHEON COMPANY AND IS RESTRICTED TO USE ONLY BY PERSONS
AUTHORIZED BY RAYTHEON COMPANY IN WRITING TO USE IT. DISCLOSURE TO
UNAUTHORIZED PERSONS WOULD LIKELY CAUSE SUBSTANTIAL COMPETITIVE HARM TO
RAYTHEON COMPANY'S BUSINESS POSITION. NEITHER SAID DOCUMENT NOR ITS
CONTENTS SHALL BE FURNISHED OR DISCLOSED TO OR COPIED OR USED BY PERSONS
OUTSIDE RAYTHEON COMPANY WITHOUT THE EXPRESS WRITTEN APPROVAL OF RAYTHEON
COMPANY.
THIS PROPRIETARY NOTICE IS NOT APPLICABLE IF DELIVERED TO THE U.S.
GOVERNMENT.
UNPUBLISHED WORK - COPYRIGHT RAYTHEON COMPANY.
-------------------------------------------------------------------------*/
#pragma once
#include "Message.hpp"
#include "MessageIDs.hpp"
#include "MessageHeader.hpp"
class WaitForLastTaskCompletionCmdMessage : public Message
{
public:
//>---------------------------------------------------------------------------
// Function: WaitForLastTaskCompletionCmdMessage
//
// Purpose: constructor
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
WaitForLastTaskCompletionCmdMessage();
//>---------------------------------------------------------------------------
// Function: WaitForLastTaskCompletionCmdMessage
//
// Purpose: copy constructor
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
WaitForLastTaskCompletionCmdMessage(const WaitForLastTaskCompletionCmdMessage &copy);
//>---------------------------------------------------------------------------
// Function: ~WaitForLastTaskCompletionCmdMessage
//
// Purpose: destructor
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
virtual ~WaitForLastTaskCompletionCmdMessage();
//>---------------------------------------------------------------------------
// Function: ExecuteMessage
//
// Purpose:
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
virtual void executeMessage();
//>---------------------------------------------------------------------------
// Function: ToString
//
// Purpose:
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
virtual std::string toString() const;
// indicate command executed successfully or not
static bool s_commandCompletionSuccess;
protected:
//>---------------------------------------------------------------------------
// Function: CloneSelf
//
// Purpose:
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
virtual Message* cloneSelf();
//>---------------------------------------------------------------------------
// Function: FormatData
//
// Purpose:
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
virtual void formatData(unsigned char* pData);
//>---------------------------------------------------------------------------
// Function: ParseData
//
// Purpose:
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
virtual void parseData(const unsigned char* pData);
private:
// do not allow
WaitForLastTaskCompletionCmdMessage &operator=(const WaitForLastTaskCompletionCmdMessage &rhs);
};

View File

@@ -0,0 +1,201 @@
#include <cerrno>
#include <cstdio>
#include <string.h>
#include <string>
#include <sstream>
#include <QUdpSocket>
#include "StringUtil.hpp"
#include "UdpSocket.hpp"
#include "Exception.hpp"
#include "AutomationMsgParser.hpp"
#include "AutomationMsgHandler.hpp"
#include "LinuxProc.hpp"
#include "MainWindow.h"
#include "ErrorLog.hpp"
//-----------------------------------------------------------------------------
UdpSocket::UdpSocket(const int& localPort):
m_localPort(localPort),
m_sock(0)
{
bool selfThrown = false;
try
{
m_sock = new QUdpSocket();
if (!m_sock->bind(QHostAddress::AnyIPv4, m_localPort))
{
selfThrown = true;
throw Exception(Q_FUNC_INFO, "QUdpSocket.bind() fails");
}
connect(m_sock, SIGNAL(readyRead()), this, SLOT(readCallBack()));
}
catch (Exception& e)
{
if (!selfThrown)
e.buildStackTrace(Q_FUNC_INFO);
throw e;
}
}
//-----------------------------------------------------------------------------
UdpSocket::UdpSocket(const int& localPort, const int& remotePort, const std::string& remoteAddr):
m_localPort(localPort),
m_remotePort(remotePort),
m_remoteAddr(remoteAddr),
m_sock(0)
{
bool selfThrown = false;
try
{
m_sock = new QUdpSocket();
if (!m_sock->bind(QHostAddress::AnyIPv4, m_localPort))
{
selfThrown = true;
throw Exception(Q_FUNC_INFO, "QUdpSocket.bind() fails");
}
}
catch (Exception& e)
{
if (!selfThrown)
e.buildStackTrace(Q_FUNC_INFO);
throw e;
}
}
//-----------------------------------------------------------------------------
UdpSocket::~UdpSocket()
{
if (m_sock != 0)
delete m_sock;
}
//-----------------------------------------------------------------------------
void UdpSocket::readCallBack()
{
std::stringstream ss;
try
{
// when data comes in
QByteArray buffer;
buffer.resize(m_sock->pendingDatagramSize());
QHostAddress sender;
quint16 senderPort;
qint64 sizeRead = m_sock->readDatagram(buffer.data(), buffer.size(), &sender, &senderPort);
m_remoteAddr = sender.toString().toStdString();
m_remotePort = senderPort;
ss << "\nReceived command from: " << sender.toString().toStdString() << ", port: " << senderPort;
LinuxProc::Instance().getMainWindow().updateStatusBox(ss.str());
qDebug() << "Message from: " << sender.toString();
qDebug() << "Message port: " << senderPort;
qDebug() << "Message: " << QString::fromStdString(Util::Strings::ByteArrayToHexString(buffer));
qDebug() << "Number of bytes: " << sizeRead;
unsigned int msgId = 0;
try {
AutomationMsgParser::instance().parseMsg(reinterpret_cast<unsigned char*>(buffer.data()), static_cast<int>(sizeRead), &msgId);
AutomationMsgHandler::instance().handleMsg(reinterpret_cast<unsigned char*>(buffer.data()), msgId);
ss.str("");
ss << "\nProcess message " << std::hex << msgId << " successful";
LinuxProc::Instance().getMainWindow().updateStatusBox(ss.str());
} catch (Exception& e) {
ss.str("");
ss << "\nProcess ";
if (msgId > 0)
ss << "message " << std::hex << msgId;
else
ss << "command";
ss << " failed";
LinuxProc::Instance().getMainWindow().updateStatusBox(ss.str());
throw;
}
}
catch (Exception& e)
{
e.buildStackTrace(Q_FUNC_INFO);
ErrorLog::Instance().log(e.getMessage(), true);
}
ss.str("");
ss << "\nWaiting for command...";
LinuxProc::Instance().getMainWindow().updateStatusBox(ss.str());
}
//-----------------------------------------------------------------------------
void UdpSocket::read(unsigned char* dataBuf, int& dataSize)
{
std::stringstream ss;
try
{
// when data comes in
QByteArray buffer;
buffer.resize(m_sock->pendingDatagramSize());
QHostAddress sender;
quint16 senderPort;
if (buffer.size() > 0)
{
qint64 sizeRead = m_sock->readDatagram(buffer.data(), buffer.size(), &sender, &senderPort);
m_remoteAddr = sender.toString().toStdString();
m_remotePort = senderPort;
dataSize = sizeRead;
if (dataSize > 0)
memcpy(dataBuf, reinterpret_cast<unsigned char*>(buffer.data()), dataSize);
}
}
catch (Exception& e)
{
e.buildStackTrace(Q_FUNC_INFO);
ErrorLog::Instance().log(e.getMessage(), true);
}
}
//-----------------------------------------------------------------------------
void UdpSocket::write(const unsigned char* pDataToWrite, const unsigned int& numBytesToWrite)
{
try
{
QByteArray databuf;
databuf = QByteArray(reinterpret_cast<const char*>(pDataToWrite), numBytesToWrite);
QHostAddress remoteHost(m_remoteAddr.c_str());
m_sock->writeDatagram(databuf, remoteHost, m_remotePort);
}
catch (Exception& e)
{
e.buildStackTrace(Q_FUNC_INFO);
throw e;
}
}

View File

@@ -0,0 +1,97 @@
// UNCLASSIFIED
/*-------------------------------------------------------------------------
RAYTHEON PROPRIETARY: THIS DOCUMENT CONTAINS DATA OR INFORMATION
PROPRIETARY TO RAYTHEON COMPANY AND IS RESTRICTED TO USE ONLY BY PERSONS
AUTHORIZED BY RAYTHEON COMPANY IN WRITING TO USE IT. DISCLOSURE TO
UNAUTHORIZED PERSONS WOULD LIKELY CAUSE SUBSTANTIAL COMPETITIVE HARM TO
RAYTHEON COMPANY'S BUSINESS POSITION. NEITHER SAID DOCUMENT NOR ITS
CONTENTS SHALL BE FURNISHED OR DISCLOSED TO OR COPIED OR USED BY PERSONS
OUTSIDE RAYTHEON COMPANY WITHOUT THE EXPRESS WRITTEN APPROVAL OF RAYTHEON
COMPANY.
THIS PROPRIETARY NOTICE IS NOT APPLICABLE IF DELIVERED TO THE U.S.
GOVERNMENT.
UNPUBLISHED WORK - COPYRIGHT RAYTHEON COMPANY.
-------------------------------------------------------------------------*/
#pragma once
#include <sys/types.h>
#include <QObject>
class QUdpSocket;
class UdpSocket: public QObject
{
Q_OBJECT
public:
//>---------------------------------------------------------------------
// Function: UdpSocket()
//
// Purpose: Constructor
//----------------------------------------------------------------------
// Arguments: none
//----------------------------------------------------------------------
// Return Value: the object
//<---------------------------------------------------------------------
UdpSocket(const int& localPort);
//>---------------------------------------------------------------------
// Function: UdpSocket()
//
// Purpose: Constructor
//----------------------------------------------------------------------
// Arguments: none
//----------------------------------------------------------------------
// Return Value: the object
//<---------------------------------------------------------------------
UdpSocket(const int& localPort, const int& remotePort, const std::string& remoteAddr);
//>---------------------------------------------------------------------
// Function: ~UdpSocket
//
// Purpose: Destroyer
//----------------------------------------------------------------------
// Arguments: none
//----------------------------------------------------------------------
// Return Value: none
//<---------------------------------------------------------------------
~UdpSocket();
//>---------------------------------------------------------------------
// Function: Read
//
// Purpose: Read from the socket
//----------------------------------------------------------------------
// Arguments: none
//----------------------------------------------------------------------
// Return Value:
//<---------------------------------------------------------------------
void read(unsigned char* dataBuf, int& dataSize);
//>---------------------------------------------------------------------
// Function: Write
//
// Purpose: Write to the socket
//----------------------------------------------------------------------
// Arguments: none
//----------------------------------------------------------------------
// Return Value: number of bytes written
//<---------------------------------------------------------------------
void write(const unsigned char* pDataToWrite, const unsigned int& numBytesToWrite);
public slots:
void readCallBack();
private:
// dont allow
UdpSocket(const UdpSocket& rhs);
UdpSocket& operator=(const UdpSocket& rhs);
int m_localPort;
int m_remotePort;
std::string m_remoteAddr;
QUdpSocket *m_sock;
};

View File

@@ -0,0 +1,95 @@
#include "UdpSocketMgr.hpp"
#include "Exception.hpp"
#include "ErrorLog.hpp"
#include "Util.hpp"
#include "UdpSocket.hpp"
#include "LinuxProc.hpp"
#include "IniFile.hpp"
#include "MainWindow.h"
#include "Message.hpp"
#include <sstream>
#include <QCoreApplication>
#include <QApplication>
#include <QDir>
#include <QMessageBox>
#include <QDateTime>
#include <QRegularExpression>
//-----------------------------------------------------------------------------
UdpSocketMgr& UdpSocketMgr::Instance()
{
static UdpSocketMgr proc;
return proc;
}
//-----------------------------------------------------------------------------
UdpSocketMgr::UdpSocketMgr():
m_udpSock(0)
{
}
//-----------------------------------------------------------------------------
void UdpSocketMgr::deleteSocket()
{
if (m_udpSock != 0)
{
delete m_udpSock;
m_udpSock = 0;
}
}
//-----------------------------------------------------------------------------
UdpSocketMgr::~UdpSocketMgr()
{
if (m_udpSock != 0)
delete m_udpSock;
}
//-----------------------------------------------------------------------------
void UdpSocketMgr::setUpUdpSocket()
{
try
{
int localPort = LinuxProc::Instance().getConfig().getInt("GENERAL", "CMD_LOCAL_PORT");
m_udpSock = new UdpSocket(localPort);
std::stringstream ss;
ss << "Setting up UDP socket, local port: " << localPort;
ss << "\n\nWaiting for command...";
LinuxProc::Instance().getMainWindow().updateStatusBox(ss.str());
} catch (Exception& e)
{
e.buildStackTrace(Q_FUNC_INFO);
throw;
}
}
//-----------------------------------------------------------------------------
void UdpSocketMgr::sendAMessage(Message &msg)
{
try
{
// just need a buffer big enough for outgoing commands
const unsigned int BUF_SIZE = 1024;
unsigned char data[BUF_SIZE];
msg.format(data);
m_udpSock->write(data, msg.getEntireMessageLength());
} catch (Exception& e)
{
e.buildStackTrace(Q_FUNC_INFO);
throw;
}
}

View File

@@ -0,0 +1,100 @@
// UNCLASSIFIED
/*-------------------------------------------------------------------------
RAYTHEON PROPRIETARY: THIS DOCUMENT CONTAINS DATA OR INFORMATION
PROPRIETARY TO RAYTHEON COMPANY AND IS RESTRICTED TO USE ONLY BY PERSONS
AUTHORIZED BY RAYTHEON COMPANY IN WRITING TO USE IT. DISCLOSURE TO
UNAUTHORIZED PERSONS WOULD LIKELY CAUSE SUBSTANTIAL COMPETITIVE HARM TO
RAYTHEON COMPANY'S BUSINESS POSITION. NEITHER SAID DOCUMENT NOR ITS
CONTENTS SHALL BE FURNISHED OR DISCLOSED TO OR COPIED OR USED BY PERSONS
OUTSIDE RAYTHEON COMPANY WITHOUT THE EXPRESS WRITTEN APPROVAL OF RAYTHEON
COMPANY.
THIS PROPRIETARY NOTICE IS NOT APPLICABLE IF DELIVERED TO THE U.S.
GOVERNMENT.
UNPUBLISHED WORK - COPYRIGHT RAYTHEON COMPANY.
-------------------------------------------------------------------------*/
#ifndef UDPSOCKETMGR_H
#define UDPSOCKETMGR_H
#include <QObject>
class UdpSocket;
class Message;
class UdpSocketMgr : public QObject
{
Q_OBJECT
public:
//>---------------------------------------------------------------------------
// Function: instance
//
// Purpose: singleton
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
static UdpSocketMgr& Instance();
//>---------------------------------------------------------------------------
// Function: ~UdpSocketMgr
//
// Purpose: Destroyer
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
~UdpSocketMgr();
//>---------------------------------------------------------------------------
// Function: sendAMessage
//
// Purpose:
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
void sendAMessage(Message& msg);
//>---------------------------------------------------------------------------
// Function: deleteSocket
//
// Purpose:
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
void deleteSocket();
//>---------------------------------------------------------------------------
// Function: setUpUdpSocket
//
// Purpose:
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
void setUpUdpSocket();
private:
//>---------------------------------------------------------------------------
// Function: UdpSocketMgr
//
// Purpose: Ctor
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
UdpSocketMgr();
UdpSocket* m_udpSock;
};
#endif

View File

@@ -0,0 +1,3 @@
#include "Constants.hpp"
std::map<Constants::ComputerHosts, std::string> Constants::ConfigSectionNameMapping::sectionMap = Constants::ConfigSectionNameMapping::createMap();

View File

@@ -0,0 +1,32 @@
#pragma once
#include <string>
#include <map>
namespace Constants
{
enum class ComputerHosts
{
VIDEO_PC,
SWDEV_PC,
SIXDOF_PC,
UNKNOWN_PC,
NUM_COMPUTER_HOSTS
};
struct ConfigSectionNameMapping
{
static std::map<ComputerHosts, std::string> createMap()
{
std::map<ComputerHosts, std::string> map {
{ComputerHosts::VIDEO_PC, "VIDEO_COMPUTER"},
{ComputerHosts::SWDEV_PC, "SWDEV_COMPUTER"},
{ComputerHosts::SIXDOF_PC, "SIXDOF_COMPUTER"}
};
return map;
}
static std::map<ComputerHosts, std::string> sectionMap;
};
}

View File

@@ -0,0 +1,159 @@
#include <unistd.h>
#include <stdio.h>
#include <sys/stat.h>
#include <iomanip>
#include <cmath>
#include <sys/types.h>
#include <utime.h>
#include <stdlib.h>
#include <stdexcept>
#include <fstream>
#include <sstream>
#include <string>
#include <chrono>
#include <QString>
#include <QDir>
#include <QRegularExpression>
#include "Util.hpp"
#include "MiscUtil.hpp"
#include "DateTimeUtil.hpp"
#include "FileSystemUtil.hpp"
#include "Exception.hpp"
#include "Timestamp.hpp"
#include "LinuxProc.hpp"
#include "MainWindow.h"
#include "ErrorLog.hpp"
//-----------------------------------------------------------------------------
void Util::KillProcess(const std::string& processName, bool updateMainWindow)
{
bool success = false;
bool processRunning = false;
std::string cmd = "";
for (int i=1; i<=6; i++)
{
std::map<std::string,std::string> processToUserMap = Util::Misc::GetUsersOfRunningProcess(processName);
if (processToUserMap.size() > 0)
{
processRunning = true;
std::stringstream ss;
ss << "Sending KILL signal to process " << processName;
if (updateMainWindow)
LinuxProc::Instance().getMainWindow().updateStatusBox(ss.str());
else
ErrorLog::Instance().log(ss.str(), false, ErrorLog::INFO);
// send KILL signal to telemetry app
if (i <= 3)
cmd = "kill -s INT "; // kill gracefully
else
cmd = "kill -9 "; // kill forcefully
cmd += processToUserMap.begin()->first;
system(cmd.c_str());
}
else
{
success = true;
break;
}
Util::DateTime::Sleep(200);
}
if (processRunning)
{
std::stringstream ss;
ss << "Killing " << processName << " ";
if (success)
{
ss << "successful";
}
else
ss << "failed";
if (updateMainWindow)
LinuxProc::Instance().getMainWindow().updateStatusBox(ss.str());
else
ErrorLog::Instance().log(ss.str(), false, ErrorLog::INFO);
}
}
//-----------------------------------------------------------------------------
void Util::PerformLogCleanUp(std::string logPath, std::string fileNameRegexPattern)
{
QDir sourceDir(logPath.c_str());
QStringList tempList = Util::FileSystem::GetListOfFilesInADirectory(sourceDir, false);
QMap<qint64, QString> msecsToFileMap;
int maxConsecutiveFileRemovals = 10;
int consecutiveFileRemovalFails = 0;
for ( int i = 0; i < tempList.size(); i++ )
{
QRegularExpression re(fileNameRegexPattern.c_str(), QRegularExpression::CaseInsensitiveOption);
QRegularExpressionMatch match = re.match(tempList[i]);
if (match.hasMatch()) {
QFileInfo fi(tempList[i]);
if (fi.size() > 0)
{
msecsToFileMap[fi.lastModified().toMSecsSinceEpoch()] = tempList[i];
}
else
{
QFile file(tempList[i]);
if (!file.remove())
{
ErrorLog::Instance().log("Cannot remove file " + tempList[i].toStdString(), false, ErrorLog::ERROR);
consecutiveFileRemovalFails++;
}
else
consecutiveFileRemovalFails = 0;
if (consecutiveFileRemovalFails == maxConsecutiveFileRemovals)
break;
}
}
}
consecutiveFileRemovalFails = 0;
QDateTime now = QDateTime::currentDateTime();
// keep logs that were created in the last 7 days
qint64 numDaysToKeepLogs = 7;
int MAX_NUM_LOGS_TO_KEEP = 30;
for (auto it = msecsToFileMap.begin(); it != msecsToFileMap.end();)
{
QFileInfo fi(it.value());
if (msecsToFileMap.size() > MAX_NUM_LOGS_TO_KEEP || fi.lastModified().daysTo(now) > numDaysToKeepLogs)
{
QFile file(it.value());
if (!file.remove())
{
ErrorLog::Instance().log("Cannot remove file " + it.value().toStdString(), false, ErrorLog::ERROR);
consecutiveFileRemovalFails++;
}
else
consecutiveFileRemovalFails = 0;
it = msecsToFileMap.erase(it);
if (consecutiveFileRemovalFails == maxConsecutiveFileRemovals)
break;
}
else
++it;
}
}
//-----------------------------------------------------------------------------

View File

@@ -0,0 +1,52 @@
// UNCLASSIFIED
/*-------------------------------------------------------------------------
RAYTHEON PROPRIETARY: THIS DOCUMENT CONTAINS DATA OR INFORMATION
PROPRIETARY TO RAYTHEON COMPANY AND IS RESTRICTED TO USE ONLY BY PERSONS
AUTHORIZED BY RAYTHEON COMPANY IN WRITING TO USE IT. DISCLOSURE TO
UNAUTHORIZED PERSONS WOULD LIKELY CAUSE SUBSTANTIAL COMPETITIVE HARM TO
RAYTHEON COMPANY'S BUSINESS POSITION. NEITHER SAID DOCUMENT NOR ITS
CONTENTS SHALL BE FURNISHED OR DISCLOSED TO OR COPIED OR USED BY PERSONS
OUTSIDE RAYTHEON COMPANY WITHOUT THE EXPRESS WRITTEN APPROVAL OF RAYTHEON
COMPANY.
THIS PROPRIETARY NOTICE IS NOT APPLICABLE IF DELIVERED TO THE U.S.
GOVERNMENT.
UNPUBLISHED WORK - COPYRIGHT RAYTHEON COMPANY.
-------------------------------------------------------------------------*/
#include <string>
#include <vector>
#include <map>
#include <QByteArray>
#include <QDir>
#include <QStringList>
#include <QDirIterator>
#include <QDateTime>
#include "Timestamp.hpp"
namespace Util
{
//>---------------------------------------------------------------------
// Function: KillProcess
//
// Purpose:
//----------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------
// Return Value:
//<---------------------------------------------------------------------
void KillProcess(const std::string& processName, bool updateMainWindow = true);
//>---------------------------------------------------------------------
// Function: KillProcess
//
// Purpose:
//----------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------
// Return Value:
//<---------------------------------------------------------------------
void PerformLogCleanUp(std::string logPath, std::string fileNameRegexPattern);
}

View File

@@ -0,0 +1,69 @@
#include "ConfigFileManager.hpp"
#include "LinuxProc.hpp"
#include "IniFile.hpp"
#include "Exception.hpp"
#include "StringUtil.hpp"
#include <QRegularExpression>
//-----------------------------------------------------------------------------
ConfigFileManager& ConfigFileManager::Instance()
{
static ConfigFileManager confgMgr;
return confgMgr;
}
//------------------------------------------------------------------------
ConfigFileManager::ConfigFileManager()
{
}
//------------------------------------------------------------------------
ConfigFileManager::~ConfigFileManager()
{
}
//------------------------------------------------------------------------
void ConfigFileManager::parseLogInfo(std::string sectionName)
{
try {
std::vector<std::string> iniKeys;
LinuxProc::Instance().getConfig().getKeys(sectionName, iniKeys);
std::vector<std::string>::iterator it;
for (it = iniKeys.begin(); it != iniKeys.end(); it++)
{
QRegularExpression re("^(test_data\\d+)[^\\d].+", QRegularExpression::CaseInsensitiveOption);
QRegularExpressionMatch match = re.match(std::string(*it).c_str());
if (match.hasMatch()) {
std::string uniqueKey = match.captured(1).toStdString();
if (m_testDataMap.find(uniqueKey) == m_testDataMap.end())
{
std::string key = uniqueKey + "_path";
TestDataInfo testData;
testData.path = LinuxProc::Instance().getConfig().getString(sectionName, key);
key = uniqueKey + "_FILE_REGEX_PATTERNS";
testData.fileRegexPatterns = LinuxProc::Instance().getConfig().getString(sectionName, key);
key = uniqueKey + "_TRANSFER_TYPE";
if (Util::Strings::StringsAreEqual(LinuxProc::Instance().getConfig().getString(sectionName, key), "move"))
{
testData.transferType = FileTransferType::MOVE;
}
key = uniqueKey + "_PERFORM_CLEAN_UP";
testData.performCleanUp = LinuxProc::Instance().getConfig().getBool(sectionName, key);
m_testDataMap[uniqueKey] = testData;
}
}
}
} catch (Exception& e) {
e.buildStackTrace(Q_FUNC_INFO);
throw;
}
}

View File

@@ -0,0 +1,122 @@
// UNCLASSIFIED
/*-------------------------------------------------------------------------
RAYTHEON PROPRIETARY: THIS DOCUMENT CONTAINS DATA OR INFORMATION
PROPRIETARY TO RAYTHEON COMPANY AND IS RESTRICTED TO USE ONLY BY PERSONS
AUTHORIZED BY RAYTHEON COMPANY IN WRITING TO USE IT. DISCLOSURE TO
UNAUTHORIZED PERSONS WOULD LIKELY CAUSE SUBSTANTIAL COMPETITIVE HARM TO
RAYTHEON COMPANY'S BUSINESS POSITION. NEITHER SAID DOCUMENT NOR ITS
CONTENTS SHALL BE FURNISHED OR DISCLOSED TO OR COPIED OR USED BY PERSONS
OUTSIDE RAYTHEON COMPANY WITHOUT THE EXPRESS WRITTEN APPROVAL OF RAYTHEON
COMPANY.
THIS PROPRIETARY NOTICE IS NOT APPLICABLE IF DELIVERED TO THE U.S.
GOVERNMENT.
UNPUBLISHED WORK - COPYRIGHT RAYTHEON COMPANY.
-------------------------------------------------------------------------*/
#pragma once
#include "CustomDataTypes.hpp"
#include <string>
#include <map>
#include<vector>
class ConfigFileManager
{
public:
enum class FileTransferType
{
COPY,
MOVE
};
struct TestDataInfo
{
std::string path;
std::string fileRegexPatterns;
FileTransferType transferType;
bool performCleanUp;
TestDataInfo():
path(),
fileRegexPatterns(),
transferType(FileTransferType::COPY),
performCleanUp(false)
{
}
};
static ConfigFileManager& Instance();
//>---------------------------------------------------------------------
// Function: ~ConfigFileManager()
//
// Purpose: destructor
//----------------------------------------------------------------------
// Arguments: none
//----------------------------------------------------------------------
// Return Value: none
//<---------------------------------------------------------------------
~ConfigFileManager();
//>---------------------------------------------------------------------
// Function: parseLogInfo()
//
// Purpose:
//
//----------------------------------------------------------------------
// Arguments: none
//----------------------------------------------------------------------
// Return Value: none
//<---------------------------------------------------------------------
void parseLogInfo(std::string sectionName);
//>---------------------------------------------------------------------
// Function: getLogMap()
//
// Purpose:
//
//----------------------------------------------------------------------
// Arguments: none
//----------------------------------------------------------------------
// Return Value: none
//<---------------------------------------------------------------------
std::map<std::string, TestDataInfo, CustomDataTypes::ci_less> getTestDataMap(){return m_testDataMap;}
private:
//>---------------------------------------------------------------------
// Function: ConfigFileManager()
//
// Purpose: constructor
//----------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------
// Return Value: none
//<---------------------------------------------------------------------
ConfigFileManager();
//>---------------------------------------------------------------------
// Function: ConfigFileManager()
//
// Purpose: copy constructor
//----------------------------------------------------------------------
// Arguments: const ConfigFileManager & - reference to ConfigFileManager obj
//----------------------------------------------------------------------
// Return Value: none
//<---------------------------------------------------------------------
ConfigFileManager(const ConfigFileManager &rhs);
//>---------------------------------------------------------------------
// Function: operator&()
//
// Purpose: assignment operator
//----------------------------------------------------------------------
// Arguments: const ConfigFileManager & - reference to ConfigFileManager obj
//----------------------------------------------------------------------
// Return Value: reference to ConfigFileManager obj
//<---------------------------------------------------------------------
ConfigFileManager &operator=(const ConfigFileManager &);
std::map<std::string, TestDataInfo, CustomDataTypes::ci_less> m_testDataMap;
};

View File

@@ -0,0 +1,68 @@
[GENERAL]
APP_SINGLETON_LOCAL_PORT = 44453
CMD_LOCAL_PORT = 44454
SHOW_MAIN_WINDOW = false
# true - log everything for debugging purposes
# false - minimum debugging
VERBOSE_LOGGING = TRUE
BASE_TEST_DATA_PATH = /duc_file_server/TestData/
[SWDEV_COMPUTER]
COMPUTER_NAME_REGEX_PATTERN = -swdev$
#COMPUTER_NAME_REGEX_PATTERN = -6700k$
SHOW_MAIN_WINDOW = true
RUN_TELEMETRY = true
#TELEMETRY_APP_PATH = /net/netapp01/vol/vol1/home/dle/Devshed/Development/Linux/Telemetry/tlm
TELEMETRY_APP_PATH = /duc_file_server/Programming/C_CPP/UdpServer/UdpServer/Debug/UdpServer
# If more than one host is moving data to main repository, only one computer should create the test folder while all other must wait
# until the folder is created
WAIT_TIME_BEFORE_CREATING_TEST_DATA_FOLDER = 3
TEST_DATA1_PATH = /duc_file_server/Programming/QTCreator/HWIL_Assistant/HWIL_Assistant/build_x64_debug/Output_Test
TEST_DATA1_FILE_REGEX_PATTERNS = _log\.txt
TEST_DATA1_TRANSFER_TYPE = move
TEST_DATA1_PERFORM_CLEAN_UP = true
#TEST_DATA2_PATH = /duc_file_server/Programming/QTCreator/HWIL_Assistant/HWIL_Assistant/build_x64_debug/Output_Test
#TEST_DATA2_FILE_REGEX_PATTERN = ^log*
#TEST_DATA2_TRANSFER_TYPE = move
#TEST_DATA2_PERFORM_CLEAN_UP = true
[SIXDOF_COMPUTER]
#COMPUTER_NAME_REGEX_PATTERN = -6dof$
COMPUTER_NAME_REGEX_PATTERN = -6700k$
SHOW_MAIN_WINDOW = true
RUN_HOSTBUS = true
HOSTBUS_APP_PATH = /duc_file_server/Programming/C_CPP/UdpServer/UdpServer/Debug/UdpServer
RUN_SIXDOF = true
SIXDOF_APP_PATH = /duc_file_server/Programming/C_CPP/UdpClient/UdpClient/Debug/UdpClient
# If more than one host is moving data to main repository, only one computer should create the test folder while all other must wait
# until the folder is created
WAIT_TIME_BEFORE_CREATING_TEST_DATA_FOLDER = 4
TEST_DATA1_PATH = /duc_file_server/Programming/QTCreator/HWIL_Assistant/HWIL_Assistant/build_x64_debug/Output_Test
TEST_DATA1_FILE_REGEX_PATTERNS = _log\.txt
TEST_DATA1_TRANSFER_TYPE = move
TEST_DATA1_PERFORM_CLEAN_UP = true
#TEST_DATA2_PATH = /duc_file_server/Programming/QTCreator/HWIL_Assistant/HWIL_Assistant/build_x64_debug/Output_Test
#TEST_DATA2_FILE_REGEX_PATTERN = ^log*
#TEST_DATA2_TRANSFER_TYPE = move
#TEST_DATA2_PERFORM_CLEAN_UP = true
[VIDEO_COMPUTER]
#COMPUTER_NAME_REGEX_PATTERN = -vcs$
COMPUTER_NAME_REGEX_PATTERN = -6700k$
SHOW_MAIN_WINDOW = true
# If more than one host is moving data to main repository, only one computer should create the test folder while all other must wait
# until the folder is created
WAIT_TIME_BEFORE_CREATING_TEST_DATA_FOLDER = 5

View File

@@ -0,0 +1,320 @@
#include "LinuxProc.hpp"
#include "MainWindow.h"
#include "FileTransferDialog.hpp"
#include "IniFile.hpp"
#include "Exception.hpp"
#include "ErrorLog.hpp"
#include "Timestamp.hpp"
#include "FileSystemUtil.hpp"
#include "DateTimeUtil.hpp"
#include "StringUtil.hpp"
#include "MiscUtil.hpp"
#include "Util.hpp"
#include "UdpSocket.hpp"
#include "Message.hpp"
#include "Condition.hpp"
#include "FileTransferThread.hpp"
#include "NetworkingThread.hpp"
#include "UdpSocketMgr.hpp"
#include "ConfigFileManager.hpp"
#include "KwScenarioStartedMessage.hpp"
#include "AreYouThereCmdMessage.hpp"
#include "RunAppThread.hpp"
#include "AutomationMsgParser.hpp"
#include "AreYouThereRspMessage.hpp"
#include <sstream>
#include <QCoreApplication>
#include <QApplication>
#include <QDir>
#include <QMessageBox>
#include <QDateTime>
#include <QRegularExpression>
#include <QMap>
//-----------------------------------------------------------------------------
LinuxProc& LinuxProc::Instance()
{
static LinuxProc proc;
return proc;
}
//-----------------------------------------------------------------------------
LinuxProc::LinuxProc():
Proc(),
m_pMainWindow(0),
m_pFileTransferDialog(0),
m_iniFile(0),
m_eventMap(),
m_fileTransferThread(0),
m_networkingThread(0),
m_runHostBusThread(0),
m_computerName(Constants::ComputerHosts::UNKNOWN_PC)
{
// all singleton classes aka [class]::instance() need to be instantiated here as they create static variables
// they all should also be instantiated in one thread, preferable the main thread. Instantiating them in multiple
// threads will make it hard for us to synchronize their destructions, as static variables are destroyed in the order
// they were created per thread
// all static variables are destroyed in the reverse order they were created per thread
// so any static variables that are dependent upon need to be instantiated first so they will be destroyed last
// Proc is the last variable to be instantiated and the first static variable to be destroyed
// as it needs to coordinate the destruction of all variables created on the heap
try {
initEvents();
// at startup, there's no command executing, so we assume this event should be signaled
getEvent(EventNames::COMMAND_EXECUTION_COMPLETE).signal();
std::string exePath = Util::FileSystem::BuildPath(QCoreApplication::applicationDirPath().toStdString());
std::string configFilePath = Util::FileSystem::BuildPath(exePath,"config.ini");
m_iniFile = new IniFile(configFilePath);
testAppSingleton();
std::string logPath = Util::FileSystem::BuildPath(exePath,"Output");
Util::FileSystem::CreateDirectory(logPath);
Util::PerformLogCleanUp(logPath, "_log\\.txt");
Timestamp time;
std::stringstream ss;
ss << time.GetCurrentDateTimeString(Timestamp::DateTimeFormat::YYYYMMDD) << "_" << Timestamp::GetCurrentDateTimeString(Timestamp::DateTimeFormat::HHMMSS, "_") << "_log.txt";
ErrorLog::Instance(Util::FileSystem::BuildPath(logPath,ss.str()));
ConfigFileManager::Instance();
UdpSocketMgr::Instance();
} catch (Exception& e) {
e.buildStackTrace(Q_FUNC_INFO);
throw;
}
}
//-----------------------------------------------------------------------------
LinuxProc::~LinuxProc()
{
LinuxProc::Instance().getEvent(EventNames::GLOBAL_QUIT).signal();
if (m_networkingThread != 0)
{
m_networkingThread->quit();
m_networkingThread->wait();
delete m_networkingThread;
}
if (m_fileTransferThread != 0)
{
m_fileTransferThread->quit();
m_fileTransferThread->waitForThreadToExit();
delete m_fileTransferThread;
}
if (KwScenarioStartedMessage::getRunAppThread() != 0)
{
KwScenarioStartedMessage::getRunAppThread()->quit();
KwScenarioStartedMessage::getRunAppThread()->waitForThreadToExit();
delete KwScenarioStartedMessage::getRunAppThread();
}
if (m_runHostBusThread != 0)
{
m_runHostBusThread->quit();
m_runHostBusThread->waitForThreadToExit();
delete m_runHostBusThread;
}
if (m_pMainWindow != 0)
{
delete m_pMainWindow;
}
if (m_pFileTransferDialog != 0)
{
delete m_pFileTransferDialog;
}
if (m_iniFile != 0)
{
delete m_iniFile;
}
// delete events
std::map<std::string, Condition *>::iterator eventIt;
for (eventIt = m_eventMap.begin(); eventIt != m_eventMap.end(); ++eventIt)
{
//std::string name = eventIt->second->GetName();
delete eventIt->second;
eventIt->second = 0;
}
}
//----------------------------------------------------------------------------
void LinuxProc::initialize()
{
try {
m_pMainWindow = new MainWindow();
m_pFileTransferDialog = new FileTransferDialog();
m_pFileTransferDialog->setWindowFlags(Qt::CustomizeWindowHint);
m_networkingThread = new NetworkingThread();
m_networkingThread->start();
m_fileTransferThread = new FileTransferThread("FileTransferThread");
m_fileTransferThread->create();
m_fileTransferThread->resume();
bool showMainWindow = m_iniFile->getBool("GENERAL", "SHOW_MAIN_WINDOW");
if (showMainWindow)
m_pMainWindow->show();
std::string sectionName = "SWDEV_COMPUTER";
std::string key = "COMPUTER_NAME_REGEX_PATTERN";
std::string computerNamePattern = m_iniFile->getString(sectionName,key);
{
QRegularExpression re(computerNamePattern.c_str(), QRegularExpression::CaseInsensitiveOption);
QRegularExpressionMatch match = re.match(Util::Misc::GetComputerName().c_str());
if (match.hasMatch())
{
m_computerName = Constants::ComputerHosts::SWDEV_PC;
}
}
if (m_computerName == Constants::ComputerHosts::UNKNOWN_PC)
{
sectionName = "SIXDOF_COMPUTER";
computerNamePattern = m_iniFile->getString(sectionName,key);
{
QRegularExpression re(computerNamePattern.c_str(), QRegularExpression::CaseInsensitiveOption);
QRegularExpressionMatch match = re.match(Util::Misc::GetComputerName().c_str());
if (match.hasMatch())
{
m_computerName = Constants::ComputerHosts::SIXDOF_PC;
std::string appPath = getConfig().getString(Constants::ConfigSectionNameMapping::sectionMap[m_computerName], "HOSTBUS_APP_PATH");
bool runApp = getConfig().getBool(Constants::ConfigSectionNameMapping::sectionMap[m_computerName], "RUN_HOSTBUS");
if (runApp)
{
m_runHostBusThread = new RunAppThread("RunHostBusThread", appPath, false);
m_runHostBusThread->create();
m_runHostBusThread->resume();
}
}
}
}
if (m_computerName == Constants::ComputerHosts::UNKNOWN_PC)
{
sectionName = "VIDEO_COMPUTER";
computerNamePattern = m_iniFile->getString(sectionName,key);
{
QRegularExpression re(computerNamePattern.c_str(), QRegularExpression::CaseInsensitiveOption);
QRegularExpressionMatch match = re.match(Util::Misc::GetComputerName().c_str());
if (match.hasMatch())
{
m_computerName = Constants::ComputerHosts::VIDEO_PC;
}
}
}
if (m_computerName != Constants::ComputerHosts::UNKNOWN_PC)
{
try
{
showMainWindow = m_iniFile->getBool(sectionName,"SHOW_MAIN_WINDOW");
if (showMainWindow)
m_pMainWindow->show();
}
catch (Exception&){}
}
m_pMainWindow->updateStatusBox("Host: " + Util::Misc::GetComputerName());
ConfigFileManager::Instance().parseLogInfo(Constants::ConfigSectionNameMapping::sectionMap[getComputerName()]);
std::map<std::string, ConfigFileManager::TestDataInfo, CustomDataTypes::ci_less> testDataMap = ConfigFileManager::Instance().getTestDataMap();
std::map<std::string, ConfigFileManager::TestDataInfo, CustomDataTypes::ci_less>::iterator it;
for (it = testDataMap.begin(); it != testDataMap.end(); it++)
{
if (it->second.performCleanUp)
{
Util::PerformLogCleanUp(it->second.path, it->second.fileRegexPatterns);
}
}
} catch (Exception& e) {
e.buildStackTrace(Q_FUNC_INFO);
throw;
}
}
//-----------------------------------------------------------------------------
void LinuxProc::testAppSingleton()
{
UdpSocket* udpSock = 0;
try {
int localPort = getConfig().getInt("GENERAL", "APP_SINGLETON_LOCAL_PORT");
int remotePort = getConfig().getInt("GENERAL", "CMD_LOCAL_PORT");
udpSock = new UdpSocket(localPort, remotePort, "localhost");
const unsigned int BUF_SIZE = 1024;
unsigned char data[BUF_SIZE];
AreYouThereCmdMessage msg;
msg.format(data);
udpSock->write(data, msg.getEntireMessageLength());
Util::DateTime::Sleep(1000);
unsigned char dataBuf[512];
int dataSize = 0;
udpSock->read(dataBuf, dataSize);
if (dataSize > 0)
{
unsigned int msgId = 0;
AutomationMsgParser::instance().parseMsg(dataBuf, dataSize, &msgId);
if (msgId == MessageIDs::ARE_YOU_THERE_RSP)
{
AreYouThereRspMessage cmd;
cmd.parse(dataBuf);
cmd.executeMessage();
}
}
delete udpSock;
} catch (Exception& e) {
if (udpSock != 0)
delete udpSock;
e.buildStackTrace(Q_FUNC_INFO);
throw;
}
}

View File

@@ -0,0 +1,165 @@
// UNCLASSIFIED
/*-------------------------------------------------------------------------
RAYTHEON PROPRIETARY: THIS DOCUMENT CONTAINS DATA OR INFORMATION
PROPRIETARY TO RAYTHEON COMPANY AND IS RESTRICTED TO USE ONLY BY PERSONS
AUTHORIZED BY RAYTHEON COMPANY IN WRITING TO USE IT. DISCLOSURE TO
UNAUTHORIZED PERSONS WOULD LIKELY CAUSE SUBSTANTIAL COMPETITIVE HARM TO
RAYTHEON COMPANY'S BUSINESS POSITION. NEITHER SAID DOCUMENT NOR ITS
CONTENTS SHALL BE FURNISHED OR DISCLOSED TO OR COPIED OR USED BY PERSONS
OUTSIDE RAYTHEON COMPANY WITHOUT THE EXPRESS WRITTEN APPROVAL OF RAYTHEON
COMPANY.
THIS PROPRIETARY NOTICE IS NOT APPLICABLE IF DELIVERED TO THE U.S.
GOVERNMENT.
UNPUBLISHED WORK - COPYRIGHT RAYTHEON COMPANY.
-------------------------------------------------------------------------*/
#ifndef LINUXPROC_H
#define LINUXPROC_H
#include "Proc.hpp"
#include "EventNames.hpp"
#include "Constants.hpp"
#include <QObject>
class MainWindow;
class FileTransferDialog;
class IniFile;
class Message;
class Condition;
class NetworkingThread;
class FileTransferThread;
class ErrorLog;
class RunAppThread;
class LinuxProc : public QObject, public Proc
{
Q_OBJECT
public:
//>---------------------------------------------------------------------------
// Function: instance
//
// Purpose: singleton
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
static LinuxProc& Instance();
//>---------------------------------------------------------------------------
// Function: ~LinuxProc
//
// Purpose: Destroyer
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
~LinuxProc();
//>---------------------------------------------------------------------------
// Function: getConfig
//
// Purpose:
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
IniFile& getConfig(){return *m_iniFile;};
//>---------------------------------------------------------------------------
// Function: getMainWindow
//
// Purpose:
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
MainWindow& getMainWindow(){return *m_pMainWindow;};
//>---------------------------------------------------------------------------
// Function: getFileTransferDialog
//
// Purpose:
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
FileTransferDialog& getFileTransferDialog(){return *m_pFileTransferDialog;};
//>---------------------------------------------------------------------------
// Function: getFileTransferThread
//
// Purpose:
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
FileTransferThread* getFileTransferThread(){return m_fileTransferThread;};
//>---------------------------------------------------------------------------
// Function: getComputerName
//
// Purpose:
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
Constants::ComputerHosts getComputerName(){return m_computerName;}
//>---------------------------------------------------------------------------
// Function: initialize
//
// Purpose:
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
void initialize();
private:
//>---------------------------------------------------------------------------
// Function: Proc
//
// Purpose: Ctor
//----------------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------------
// Return Value:
//----------------------------------------------------------------------------
LinuxProc();
//>---------------------------------------------------------------------
// Function: testAppSingleton()
//
// Purpose: Make sure only single instance of this app is running
//----------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------
// Return Value: none
//<---------------------------------------------------------------------
void testAppSingleton();
MainWindow* m_pMainWindow;
FileTransferDialog* m_pFileTransferDialog;
IniFile* m_iniFile;
std::map<std::string, Condition*> m_eventMap;
FileTransferThread* m_fileTransferThread;
NetworkingThread* m_networkingThread;
RunAppThread* m_runHostBusThread;
Constants::ComputerHosts m_computerName;
};
#endif

View File

@@ -0,0 +1,10 @@
[Desktop Entry]
Version=1.0
Name=HWIL_Assistant
Exec=/Released/HWIL_Assistant/HWIL_Assistant
Icon=/Released/HWIL_Assistant/assistant.png
Terminal=false
Type=Application
StartupNotify=true
Actions=new-window;new-private-window;
Name[en_US]=HWIL_Assistant

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

View File

@@ -0,0 +1,319 @@
#include "FileTransferThread.hpp"
#include "LinuxProc.hpp"
#include "FileTransferDialog.hpp"
#include "Condition.hpp"
#include "FileSystemUtil.hpp"
#include "DateTimeUtil.hpp"
#include "StringUtil.hpp"
#include "Exception.hpp"
#include "MainWindow.h"
#include "Timestamp.hpp"
#include "ErrorLog.hpp"
#include "IniFile.hpp"
#include <sstream>
#include <QDirIterator>
#include <QDir>
//------------------------------------------------------------------------
FileTransferThread::FileTransferThread(const std::string& name):
Thread(name),
m_shallWeQuit(false),
m_shallWeSuspend(false),
m_startCondition(name + "_START_EVENT"),
m_totalSizeInBytes(0),
numFilesCopySuccess(0),
numFilesCopyFail(0)
{
}
//------------------------------------------------------------------------
FileTransferThread::~FileTransferThread()
{
}
//------------------------------------------------------------------------
void FileTransferThread::operator()()
{
ErrorLog::Instance().log(getName() + " started", false, ErrorLog::INFO);
try {
Condition& startFileTransferEvent = LinuxProc::Instance().getEvent(EventNames::START_FILE_TRANSFER);
while (true)
{
startFileTransferEvent.wait();
if (ShallWeExit() == true)
break;
LinuxProc::Instance().getFileTransferDialog().showWindow(true);
try {
gatherInfo();
transferFiles();
} catch (Exception e) {
e.buildStackTrace(Q_FUNC_INFO);
ErrorLog::Instance().log(e.getMessage(), false);
}
Condition& commandExecutingEvent = LinuxProc::Instance().getEvent(EventNames::COMMAND_EXECUTTION_IN_PROGRESS);
commandExecutingEvent.reset(); // we are not executing command
Condition& completeEvent = LinuxProc::Instance().getEvent(EventNames::COMMAND_EXECUTION_COMPLETE);
completeEvent.signal(); // we are done executing
LinuxProc::Instance().getFileTransferDialog().showWindow(false);
m_sourceDirList.clear();
m_qFileList.clear();
m_fileList.clear();
if (ShallWeExit() == true)
break;
}
ErrorLog::Instance().log(getName() + " exited", false, ErrorLog::INFO);
} catch (Exception e) {
ErrorLog::Instance().log(getName() + " exited", false, ErrorLog::INFO);
e.buildStackTrace(Q_FUNC_INFO);
ErrorLog::Instance().log(e.getMessage(), false);
}
}
//------------------------------------------------------------------------
void FileTransferThread::gatherInfo()
{
try
{
FileTransferInfo fileInfo;
for ( int i = 0; i < m_sourceDirList.size(); i++ )
{
QDir sourceDir(m_sourceDirList[i]);
QStringList fileList = Util::FileSystem::GetListOfFilesInADirectory(sourceDir, true);
fileInfo.baseSourceDir = m_sourceDirList[i].toStdString();
for ( int j = 0; j < fileList.size(); j++ )
{
fileInfo.sourceFile = fileList[j].toStdString();
m_qFileList.append(fileInfo);
QFileInfo fi(QString(fileInfo.sourceFile.c_str()));
m_totalSizeInBytes += fi.size();
}
}
for ( int i = 0; i < m_fileList.size(); i++ )
{
fileInfo.baseSourceDir = Util::FileSystem::ExtractDirectory(m_fileList[i].toStdString());
fileInfo.sourceFile = m_fileList[i].toStdString();
m_qFileList.append(fileInfo);
QFileInfo fi(QString(fileInfo.sourceFile.c_str()));
m_totalSizeInBytes += fi.size();
}
std::stringstream ss;
ss << "Moving " << m_qFileList.size() << " items (" << Util::FileSystem::DescribeFileSize(m_totalSizeInBytes) << ")";
LinuxProc::Instance().getFileTransferDialog().updateLabel(FileTransferDialog::HEADER_LBL, ss.str());
}
catch (Exception& e)
{
e.buildStackTrace(Q_FUNC_INFO);
throw e;
}
}
//------------------------------------------------------------------------
void FileTransferThread::transferFiles()
{
try
{
numFilesCopySuccess = 0;
numFilesCopyFail = 0;
std::string destFile;
FileTransferInfo fileInfo;
int waitTimeBeforeCreatingTestFolder = LinuxProc::Instance().getConfig().getInt(Constants::ConfigSectionNameMapping::sectionMap[LinuxProc::Instance().getComputerName()], "WAIT_TIME_BEFORE_CREATING_TEST_DATA_FOLDER");
int timeElapse = 1;
while (!Util::FileSystem::DirExists(m_destDir))
{
if (timeElapse++ > waitTimeBeforeCreatingTestFolder)
{
Util::FileSystem::CreateDirectory(m_destDir);
break;
}
Util::DateTime::Sleep(1000);
}
LinuxProc::Instance().getFileTransferDialog().startTheTimer();
int itemsRemaining = m_qFileList.size();
int64_t tempTotalSizeInBytes = m_totalSizeInBytes;
for ( int i=0; i < m_qFileList.size(); i++ )
{
fileInfo = m_qFileList[i];
QFileInfo fi(fileInfo.sourceFile.c_str());
int64_t fileSize = fi.size();
LinuxProc::Instance().getFileTransferDialog().updateLabel(FileTransferDialog::FILE_NAME_LBL, Util::Strings::ShortenStringToSize(fi.fileName().toStdString(),45) + " (" + Util::FileSystem::DescribeFileSize(fileSize) + ")");
LinuxProc::Instance().getFileTransferDialog().updateLabel(FileTransferDialog::FROM_DIR_LBL, Util::Strings::ShortenStringToSize(Util::FileSystem::BuildPath(fi.absolutePath().toStdString(),""),50));
LinuxProc::Instance().getFileTransferDialog().updateLabel(FileTransferDialog::ITEMS_REMAIN_LBL, QString::number(itemsRemaining).toStdString() + " (" + Util::FileSystem::DescribeFileSize(m_totalSizeInBytes) + ")");
LinuxProc::Instance().getFileTransferDialog().updateLabel(FileTransferDialog::TO_DIR_LBL, Util::Strings::ShortenStringToSize(destFile,50));
destFile = Util::FileSystem::BuildPath(m_destDir, fi.fileName().toStdString());
QFile sourceFile(fileInfo.sourceFile.c_str());
std::stringstream ss;
if (fileSize > 0)
{
QDateTime modifiedDate = fi.lastModified();
QDateTime accessedDate = fi.lastRead();
// moving the file
bool success = sourceFile.rename(destFile.c_str());
ss << "Copying " << fi.fileName().toStdString() << " - ";
if (success)
{
Util::FileSystem::ChangeFileDateTime(destFile, modifiedDate, accessedDate);
ss << "SUCCESS";
numFilesCopySuccess++;
}
else
{
ss << "FAIL";
numFilesCopyFail++;
}
ss << "\n "
<< "From: " << Util::FileSystem::BuildPath(fi.absolutePath().toStdString(),"")
<< "\n "
<< "To: ";
QFileInfo fi2(destFile.c_str());
ss << Util::FileSystem::BuildPath(fi2.absolutePath().toStdString(),"");
}
else
{
numFilesCopySuccess++;
QFile file(fileInfo.sourceFile.c_str());
// remove empty file
bool success = file.remove();
ss << "Removing " << fi.fileName().toStdString() << ", empty file - ";
if (success)
ss << "SUCCESS";
else
ss << "FAIL";
ss << "\n "
<< "From: " << Util::FileSystem::BuildPath(fi.absolutePath().toStdString(),"");
}
ss << "\n";
ErrorLog::Instance().log(ss.str(), false, ErrorLog::INFO);
m_totalSizeInBytes -= fileSize;
itemsRemaining--;
}
LinuxProc::Instance().getFileTransferDialog().stopTheTimer();
for ( int i=0; i < m_sourceDirList.size(); i++)
{
removeEmptyFolders(m_sourceDirList[i]);
}
{
std::stringstream ss;
ss << "************************************************************************************"
<< "\n"
<< " Summary:"
<< "\n"
<< " Total files: " << m_qFileList.size()
<< "\n"
<< " # files copied with success: " << numFilesCopySuccess
<< "\n"
<< " # files copied with failure: " << numFilesCopyFail
<< "\n"
<< " Total size of all files: " << Util::FileSystem::DescribeFileSize(tempTotalSizeInBytes)
<< "\n"
<< " Transfer time: " << Util::DateTime::DescribeTimeElapsed(LinuxProc::Instance().getFileTransferDialog().getElapsedTimeSec())
<< "\n";
if (LinuxProc::Instance().getFileTransferDialog().getElapsedTimeSec() > 0)
{
ss << " Estimated transfer speed: " << Util::FileSystem::DescribeFileSize(tempTotalSizeInBytes / LinuxProc::Instance().getFileTransferDialog().getElapsedTimeSec()) << " / s"
<< "\n";
}
ss << "************************************************************************************"
<< "\n";
ErrorLog::Instance().log(ss.str(), false, ErrorLog::INFO);
}
}
catch (Exception& e)
{
e.buildStackTrace(Q_FUNC_INFO);
throw e;
}
}
//------------------------------------------------------------------------
void FileTransferThread::removeEmptyFolders(QString topLevelDir)
{
try
{
QDirIterator it(topLevelDir, QDir::Dirs | QDir::NoSymLinks | QDir::NoDotAndDotDot);
while(it.hasNext())
{
it.next();
removeEmptyFolders(it.filePath());
}
QDir dir(topLevelDir);
dir.rmdir(dir.absolutePath());
}
catch (Exception& e)
{
e.buildStackTrace(Q_FUNC_INFO);
throw e;
}
}
//------------------------------------------------------------------------
bool FileTransferThread::ShallWeExit()
{
return m_shallWeQuit;
}
//------------------------------------------------------------------------
bool FileTransferThread::ShallWeSuspend()
{
return m_shallWeSuspend;
}
//------------------------------------------------------------------------
void FileTransferThread::quit()
{
m_shallWeQuit = true;
Condition& startFileTransferEvent = LinuxProc::Instance().getEvent(EventNames::START_FILE_TRANSFER);
startFileTransferEvent.signal();
}

View File

@@ -0,0 +1,207 @@
// UNCLASSIFIED
/*-------------------------------------------------------------------------
RAYTHEON PROPRIETARY: THIS DOCUMENT CONTAINS DATA OR INFORMATION
PROPRIETARY TO RAYTHEON COMPANY AND IS RESTRICTED TO USE ONLY BY PERSONS
AUTHORIZED BY RAYTHEON COMPANY IN WRITING TO USE IT. DISCLOSURE TO
UNAUTHORIZED PERSONS WOULD LIKELY CAUSE SUBSTANTIAL COMPETITIVE HARM TO
RAYTHEON COMPANY'S BUSINESS POSITION. NEITHER SAID DOCUMENT NOR ITS
CONTENTS SHALL BE FURNISHED OR DISCLOSED TO OR COPIED OR USED BY PERSONS
OUTSIDE RAYTHEON COMPANY WITHOUT THE EXPRESS WRITTEN APPROVAL OF RAYTHEON
COMPANY.
THIS PROPRIETARY NOTICE IS NOT APPLICABLE IF DELIVERED TO THE U.S.
GOVERNMENT.
UNPUBLISHED WORK - COPYRIGHT RAYTHEON COMPANY.
-------------------------------------------------------------------------*/
#ifndef FILETRANSFERTHREAD_H
#define FILETRANSFERTHREAD_H
#include "Thread.hpp"
#include <QDir>
class FileTransferThread : public Thread
{
public:
struct FileTransferInfo {
std::string baseSourceDir;
std::string sourceFile;
};
//>---------------------------------------------------------------------
// Function: FileTransferThread
//
// Purpose: constructor
//----------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------
// Return Value: none
//<---------------------------------------------------------------------
FileTransferThread(const std::string& name);
//>---------------------------------------------------------------------
// Function: ~FileTransferThread
//
// Purpose: destructor
//----------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------
// Return Value: none
//<---------------------------------------------------------------------
virtual ~FileTransferThread();
//>---------------------------------------------------------------------
// Function: operator
//
// Purpose:
//----------------------------------------------------------------------
// Arguments:
//
//----------------------------------------------------------------------
// Return Value: none
//<---------------------------------------------------------------------
virtual void operator()();
//>---------------------------------------------------------------------
// Function: StartThread()
//
// Purpose: Commands the thread to run
//----------------------------------------------------------------------
// Arguments: none
//----------------------------------------------------------------------
// Return Value: nonestd
//<---------------------------------------------------------------------
virtual void startThread(){m_startCondition.signal();}
//>---------------------------------------------------------------------
// Function: SuspendThread()
//
// Purpose: Commands the thread to pause its execution
//----------------------------------------------------------------------
// Arguments: none
//----------------------------------------------------------------------
// Return Value: none
//<---------------------------------------------------------------------
virtual void suspendThread(){m_shallWeSuspend = true;}
//>---------------------------------------------------------------------
// Function: Quit()
//
// Purpose: Command the thread to exit
//----------------------------------------------------------------------
// Arguments: none
//----------------------------------------------------------------------
// Return Value: none
//<---------------------------------------------------------------------
virtual void quit();
//>---------------------------------------------------------------------
// Function: addSourceDir
//
// Purpose:
//----------------------------------------------------------------------
// Arguments:
// sourceDir -
//----------------------------------------------------------------------
// Return Value: none
//<---------------------------------------------------------------------
void addSourceDir(std::string sourceDir) {m_sourceDirList.append(sourceDir.c_str());}
//>---------------------------------------------------------------------
// Function: addSourceDir
//
// Purpose:
//----------------------------------------------------------------------
// Arguments:
// sourceDir -
//----------------------------------------------------------------------
// Return Value: none
//<---------------------------------------------------------------------
void addSourceFile(std::string sourceDir) {m_fileList.append(sourceDir.c_str());}
//>---------------------------------------------------------------------
// Function: setDestDir
//
// Purpose:
//----------------------------------------------------------------------
// Arguments:
// destDir -
//----------------------------------------------------------------------
// Return Value: none
//<---------------------------------------------------------------------
void setDestDir(std::string destDir) {m_destDir = destDir;};
//>---------------------------------------------------------------------
// Function: setUut
//
// Purpose:
//----------------------------------------------------------------------
// Arguments:
// destDir -
//----------------------------------------------------------------------
// Return Value: none
//<---------------------------------------------------------------------
void setUut(std::string uut) {m_uut = uut;};
private:
// do not allow
FileTransferThread();
FileTransferThread(const FileTransferThread &copy);
FileTransferThread &operator=(const FileTransferThread &rhs);
//>---------------------------------------------------------------------
// Function: gatherInfo
//
// Purpose:
//----------------------------------------------------------------------
// Arguments:
//
//----------------------------------------------------------------------
// Return Value: none
//<---------------------------------------------------------------------
void gatherInfo();
//>---------------------------------------------------------------------
// Function: transferFiles
//
// Purpose:
//----------------------------------------------------------------------
// Arguments:
//
//----------------------------------------------------------------------
// Return Value: none
//<---------------------------------------------------------------------
void transferFiles();
//>---------------------------------------------------------------------
// Function: removeEmptyFolders
//
// Purpose:
//----------------------------------------------------------------------
// Arguments:
//
//----------------------------------------------------------------------
// Return Value: none
//<---------------------------------------------------------------------
void removeEmptyFolders(QString topLevelDir);
bool ShallWeSuspend();
bool ShallWeExit();
bool m_shallWeQuit;
bool m_shallWeSuspend;
Condition m_startCondition;
QStringList m_sourceDirList;
QStringList m_fileList;
std::string m_destDir;
std::string m_uut;
QList<FileTransferInfo> m_qFileList;
int64_t m_totalSizeInBytes;
int numFilesCopySuccess;
int numFilesCopyFail;
};
#endif // FILETRANSFERTHREAD_H

View File

@@ -0,0 +1,40 @@
#include "NetworkingThread.hpp"
#include "UdpSocketMgr.hpp"
#include "FileTransferDialog.hpp"
#include "Condition.hpp"
#include "Util.hpp"
#include "Exception.hpp"
#include "MainWindow.h"
#include "ErrorLog.hpp"
#include "Proc.hpp"
#include <sstream>
NetworkingThread::NetworkingThread()
{
// Setup callback for cleanup when it finishes
connect(this, SIGNAL(finished()),
this, SLOT(deleteLater()));
}
NetworkingThread::~NetworkingThread()
{
}
void NetworkingThread::run()
{
ErrorLog::Instance().log("NetworkingThread started", false, ErrorLog::INFO);
try {
// signals and slots for this QUdpSocket object will be handled by this thread
UdpSocketMgr::Instance().setUpUdpSocket();
} catch (Exception& e) {
e.buildStackTrace(Q_FUNC_INFO);
ErrorLog::Instance().log(e.getMessage(), false);
}
exec(); // run the event loop.
ErrorLog::Instance().log("NetworkingThread exited", false, ErrorLog::INFO);
}

View File

@@ -0,0 +1,63 @@
// UNCLASSIFIED
/*-------------------------------------------------------------------------
RAYTHEON PROPRIETARY: THIS DOCUMENT CONTAINS DATA OR INFORMATION
PROPRIETARY TO RAYTHEON COMPANY AND IS RESTRICTED TO USE ONLY BY PERSONS
AUTHORIZED BY RAYTHEON COMPANY IN WRITING TO USE IT. DISCLOSURE TO
UNAUTHORIZED PERSONS WOULD LIKELY CAUSE SUBSTANTIAL COMPETITIVE HARM TO
RAYTHEON COMPANY'S BUSINESS POSITION. NEITHER SAID DOCUMENT NOR ITS
CONTENTS SHALL BE FURNISHED OR DISCLOSED TO OR COPIED OR USED BY PERSONS
OUTSIDE RAYTHEON COMPANY WITHOUT THE EXPRESS WRITTEN APPROVAL OF RAYTHEON
COMPANY.
THIS PROPRIETARY NOTICE IS NOT APPLICABLE IF DELIVERED TO THE U.S.
GOVERNMENT.
UNPUBLISHED WORK - COPYRIGHT RAYTHEON COMPANY.
-------------------------------------------------------------------------*/
#ifndef NETWORKINGTHREAD_H
#define NETWORKINGTHREAD_H
#include <QThread>
class MainWindow;
class NetworkingThread : public QThread
{
Q_OBJECT
public:
//>---------------------------------------------------------------------
// Function: NetworkingThread
//
// Purpose: constructor
//----------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------
// Return Value: none
//<---------------------------------------------------------------------
NetworkingThread();
//>---------------------------------------------------------------------
// Function: ~NetworkingThread
//
// Purpose: destructor
//----------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------
// Return Value: none
//<---------------------------------------------------------------------
~NetworkingThread();
private:
//>---------------------------------------------------------------------
// Function: run
//
// Purpose:
//----------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------
// Return Value: none
//<---------------------------------------------------------------------
void run();
};
#endif

View File

@@ -0,0 +1,168 @@
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <sstream>
#include <stdexcept>
#include <iostream>
#include "qprocess.h"
#include "ErrorLog.hpp"
#include "RunAppThread.hpp"
#include "Exception.hpp"
#include "LinuxProc.hpp"
#include "FileSystemUtil.hpp"
#include "Util.hpp"
#include "IniFile.hpp"
#include "MainWindow.h"
//------------------------------------------------------------------------
RunAppThread::RunAppThread(const std::string& name, const std::string& appPath, const bool& runAppInLoop) :
Thread(name),
m_shallWeQuit(false),
m_shallWeSuspend(false),
m_runAppInLoop(runAppInLoop),
m_appPath(appPath),
m_startCondition(name + "_START_EVENT")
{
try
{
}
catch (Exception& e)
{
e.buildStackTrace(Q_FUNC_INFO);
throw e;
}
catch (...)
{
throw Exception(Q_FUNC_INFO, "caught unknown error");
}
}
//------------------------------------------------------------------------
RunAppThread::~RunAppThread()
{
}
//------------------------------------------------------------------------
void RunAppThread::operator()()
{
ErrorLog::Instance().log(getName() + " started", false, ErrorLog::INFO);
try {
if (Util::FileSystem::FileExists(m_appPath))
{
if (m_runAppInLoop)
runAppInLoop();
else
runAppOnce();
}
else
{
throw Exception(Q_FUNC_INFO,m_appPath + " does not exist");
}
ErrorLog::Instance().log(getName() + " exited", false, ErrorLog::INFO);
} catch (Exception& e) {
e.buildStackTrace(Q_FUNC_INFO);
ErrorLog::Instance().log(e.getMessage(), false);
ErrorLog::Instance().log(getName() + " exited", false, ErrorLog::INFO);
}
}
//------------------------------------------------------------------------
void RunAppThread::runAppInLoop()
{
try
{
std::string appName = Util::FileSystem::ExtractFilename(m_appPath);
while (true)
{
// wait here until command to start
m_startCondition.wait();
if (shallWeExit() == true)
break;
LinuxProc::Instance().getMainWindow().updateStatusBox("Running " + appName);
chdir(Util::FileSystem::ExtractDirectory(m_appPath).c_str());
std::string cmd = "./" + appName;
system(cmd.c_str());
LinuxProc::Instance().getMainWindow().updateStatusBox(m_appPath + " has exited");
if (shallWeExit() == true)
break;
}
}
catch (Exception& e)
{
e.buildStackTrace(Q_FUNC_INFO);
throw;
}
catch (...)
{
}
}
//------------------------------------------------------------------------
void RunAppThread::runAppOnce()
{
try
{
std::string appName = Util::FileSystem::ExtractFilename(m_appPath);
LinuxProc::Instance().getMainWindow().updateStatusBox("Running " + appName);
chdir(Util::FileSystem::ExtractDirectory(m_appPath).c_str());
std::string cmd = "./" + appName;
system(cmd.c_str());
LinuxProc::Instance().getMainWindow().updateStatusBox(m_appPath + " has exited");
}
catch (Exception& e)
{
e.buildStackTrace(Q_FUNC_INFO);
throw;
}
catch (...)
{
}
}
//------------------------------------------------------------------------
void RunAppThread::quit()
{
if (m_runAppInLoop)
{
m_shallWeQuit = true;
startThread();
}
else
{
Util::KillProcess(Util::FileSystem::ExtractFilename(m_appPath), false);
}
}
//------------------------------------------------------------------------
bool RunAppThread::shallWeExit()
{
return m_shallWeQuit;
}
//------------------------------------------------------------------------
bool RunAppThread::shallWeSuspend()
{
return m_shallWeSuspend;
}

View File

@@ -0,0 +1,111 @@
// UNCLASSIFIED
/*-------------------------------------------------------------------------
RAYTHEON PROPRIETARY: THIS DOCUMENT CONTAINS DATA OR INFORMATION
PROPRIETARY TO RAYTHEON COMPANY AND IS RESTRICTED TO USE ONLY BY PERSONS
AUTHORIZED BY RAYTHEON COMPANY IN WRITING TO USE IT. DISCLOSURE TO
UNAUTHORIZED PERSONS WOULD LIKELY CAUSE SUBSTANTIAL COMPETITIVE HARM TO
RAYTHEON COMPANY'S BUSINESS POSITION. NEITHER SAID DOCUMENT NOR ITS
CONTENTS SHALL BE FURNISHED OR DISCLOSED TO OR COPIED OR USED BY PERSONS
OUTSIDE RAYTHEON COMPANY WITHOUT THE EXPRESS WRITTEN APPROVAL OF RAYTHEON
COMPANY.
THIS PROPRIETARY NOTICE IS NOT APPLICABLE IF DELIVERED TO THE U.S.
GOVERNMENT.
UNPUBLISHED WORK - COPYRIGHT RAYTHEON COMPANY.
-------------------------------------------------------------------------*/
#pragma once
#include "Thread.hpp"
class RunAppThread : public Thread
{
public:
//>---------------------------------------------------------------------
// Function: Thread()
//
// Purpose: constructor
//----------------------------------------------------------------------
// Arguments: name - the name of this thread
// streamName - the hsdc stream name to read from
// pVideoFrameTableAllocated - the buffer to put the data we read into
// pProc - the process this thread is running under
//----------------------------------------------------------------------
// Return Value: none
//<---------------------------------------------------------------------
RunAppThread(const std::string& threadName, const std::string& appPath, const bool& runAppInLoop);
//>---------------------------------------------------------------------
// Function: ~Thread()
//
// Purpose: destructor
//----------------------------------------------------------------------
// Arguments: none
//----------------------------------------------------------------------
// Return Value: none
//<---------------------------------------------------------------------
virtual ~RunAppThread();
//>---------------------------------------------------------------------
// Function: operator()()
//
// Purpose: where all the action is in the derived classes
//----------------------------------------------------------------------
// Arguments: none
//----------------------------------------------------------------------
// Return Value: none
//<---------------------------------------------------------------------
virtual void operator()();
//>---------------------------------------------------------------------
// Function: StartThread()
//
// Purpose: Commands the thread to run
//----------------------------------------------------------------------
// Arguments: none
//----------------------------------------------------------------------
// Return Value: nonestd
//<---------------------------------------------------------------------
virtual void startThread(){m_startCondition.signal();}
//>---------------------------------------------------------------------
// Function: SuspendThread()
//
// Purpose: Commands the thread to pause its execution
//----------------------------------------------------------------------
// Arguments: none
//----------------------------------------------------------------------
// Return Value: none
//<---------------------------------------------------------------------
virtual void suspendThread(){m_shallWeSuspend = true;}
//>---------------------------------------------------------------------
// Function: Quit()
//
// Purpose: Command the thread to exit
//----------------------------------------------------------------------
// Arguments: none
//----------------------------------------------------------------------
// Return Value: none
//<---------------------------------------------------------------------
virtual void quit();
private:
// do not allow
RunAppThread();
RunAppThread(const RunAppThread &copy);
RunAppThread &operator=(const RunAppThread &rhs);
bool shallWeSuspend();
bool shallWeExit();
void runAppInLoop();
void runAppOnce();
bool m_shallWeQuit;
bool m_shallWeSuspend;
bool m_runAppInLoop;
std::string m_appPath;
Condition m_startCondition;
};

View File

@@ -0,0 +1,133 @@
#include "FileTransferDialog.hpp"
#include "ui_FileTransferDialog.h"
#include "DateTimeUtil.hpp"
//------------------------------------------------------------------------
FileTransferDialog::FileTransferDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::FileTransferDialog),
m_timeElapsedSec(0)
{
ui->setupUi(this);
#ifndef LINUX_PLATFORM
QFont f( "Segoe UI", 12, QFont::Normal);
ui->Header->setFont( f);
ui->label1->setFont(f);
ui->label1_2->setFont(f);
ui->label1_3->setFont(f);
ui->label1_4->setFont(f);
ui->label1_5->setFont(f);
ui->FileName->setFont(f);
ui->From->setFont(f);
ui->To->setFont(f);
ui->ItemsRemain->setFont(f);
ui->TimeElapsed->setFont(f);
ui->label1_4->setGeometry(ui->label1_4->x(), ui->label1_4->y(), ui->label1_4->width() + 5, ui->label1_4->height());
#endif
connect(this, SIGNAL(LabelChanged(int,QString)), this, SLOT(on_LabelChanged(int,QString)));
connect(this, SIGNAL(ShowWindowChanged(bool)), this, SLOT(on_ShowWindowChanged(bool)));
connect(this, SIGNAL(startTheTimerChanged()), this, SLOT(on_startTheTimer()));
connect(this, SIGNAL(stopTheTimerChanged()), this, SLOT(on_stopTheTimer()));
}
//------------------------------------------------------------------------
FileTransferDialog::~FileTransferDialog()
{
delete ui;
}
//------------------------------------------------------------------------
void FileTransferDialog::updateLabel(LABEL label, std::string msg)
{
emit LabelChanged(label, msg.c_str());
}
//------------------------------------------------------------------------
void FileTransferDialog::on_LabelChanged(int label, QString msg)
{
if (label == HEADER_LBL)
{
ui->Header->setText(msg);
}
else if (label == FILE_NAME_LBL)
{
ui->FileName->setText(msg);
}
else if (label == FROM_DIR_LBL)
{
ui->From->setText(msg);
}
else if (label == TO_DIR_LBL)
{
ui->To->setText(msg);
}
else if (label == ITEMS_REMAIN_LBL)
{
ui->ItemsRemain->setText(msg);
}
else if (label == TIME_ELAPSED)
{
ui->TimeElapsed->setText(msg);
}
}
//------------------------------------------------------------------------
void FileTransferDialog::showWindow(bool show)
{
emit ShowWindowChanged(show);
}
//------------------------------------------------------------------------
void FileTransferDialog::on_ShowWindowChanged(bool show)
{
if (show)
this->show();
else
this->hide();
}
//------------------------------------------------------------------------
void FileTransferDialog::on_startTheTimer()
{
m_timeElapsedSec = 0;
m_timerId = startTimer(1000);
}
//------------------------------------------------------------------------
void FileTransferDialog::on_stopTheTimer()
{
killTimer(m_timerId);
}
//------------------------------------------------------------------------
void FileTransferDialog::timerEvent(QTimerEvent *)
{
ui->TimeElapsed->setText(Util::DateTime::DescribeTimeElapsed(m_timeElapsedSec++).c_str());
}
//------------------------------------------------------------------------
void FileTransferDialog::startTheTimer()
{
emit startTheTimerChanged();
}
//------------------------------------------------------------------------
void FileTransferDialog::stopTheTimer()
{
emit stopTheTimerChanged();
}

View File

@@ -0,0 +1,188 @@
// UNCLASSIFIED
/*-------------------------------------------------------------------------
RAYTHEON PROPRIETARY: THIS DOCUMENT CONTAINS DATA OR INFORMATION
PROPRIETARY TO RAYTHEON COMPANY AND IS RESTRICTED TO USE ONLY BY PERSONS
AUTHORIZED BY RAYTHEON COMPANY IN WRITING TO USE IT. DISCLOSURE TO
UNAUTHORIZED PERSONS WOULD LIKELY CAUSE SUBSTANTIAL COMPETITIVE HARM TO
RAYTHEON COMPANY'S BUSINESS POSITION. NEITHER SAID DOCUMENT NOR ITS
CONTENTS SHALL BE FURNISHED OR DISCLOSED TO OR COPIED OR USED BY PERSONS
OUTSIDE RAYTHEON COMPANY WITHOUT THE EXPRESS WRITTEN APPROVAL OF RAYTHEON
COMPANY.
THIS PROPRIETARY NOTICE IS NOT APPLICABLE IF DELIVERED TO THE U.S.
GOVERNMENT.
UNPUBLISHED WORK - COPYRIGHT RAYTHEON COMPANY.
-------------------------------------------------------------------------*/
#ifndef FILETRANSFERDIALOG_HPP
#define FILETRANSFERDIALOG_HPP
#include <QDialog>
namespace Ui {
class FileTransferDialog;
}
class FileTransferDialog : public QDialog
{
Q_OBJECT
public:
enum LABEL
{
HEADER_LBL,
FILE_NAME_LBL,
FROM_DIR_LBL,
TO_DIR_LBL,
ITEMS_REMAIN_LBL,
TIME_ELAPSED
};
//>---------------------------------------------------------------------
// Function: FileTransferDialog
//
// Purpose: constructor
//----------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------
// Return Value: none
//<---------------------------------------------------------------------
explicit FileTransferDialog(QWidget *parent = nullptr);
//>---------------------------------------------------------------------
// Function: ~FileTransferDialog
//
// Purpose: destructor
//----------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------
// Return Value: none
//<---------------------------------------------------------------------
~FileTransferDialog();
//>---------------------------------------------------------------------
// Function: updateLabel
//
// Purpose:
//----------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------
// Return Value: none
//<---------------------------------------------------------------------
void updateLabel(LABEL label, std::string msg);
//>---------------------------------------------------------------------
// Function: showWindow
//
// Purpose:
//----------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------
// Return Value: none
//<---------------------------------------------------------------------
void showWindow(bool show);
//>---------------------------------------------------------------------
// Function: startTheTimer
//
// Purpose: wrapper to emit a signal
//----------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------
// Return Value: none
//<---------------------------------------------------------------------
void startTheTimer();
//>---------------------------------------------------------------------
// Function: stopTheTimer
//
// Purpose: wrapper to emit a signal
//----------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------
// Return Value: none
//<---------------------------------------------------------------------
void stopTheTimer();
//>---------------------------------------------------------------------
// Function: getElapsedTimeSec
//
// Purpose:
//----------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------
// Return Value: none
//<---------------------------------------------------------------------
int getElapsedTimeSec() {return m_timeElapsedSec;};
public slots:
//>---------------------------------------------------------------------
// Function: on_LabelChanged
//
// Purpose: change the text of a label
//----------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------
// Return Value: none
//<---------------------------------------------------------------------
void on_LabelChanged(int label, QString msg);
//>---------------------------------------------------------------------
// Function: on_ShowWindowChanged
//
// Purpose: show or hide this dialog
//----------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------
// Return Value: none
//<---------------------------------------------------------------------
void on_ShowWindowChanged(bool show);
//>---------------------------------------------------------------------
// Function: on_startTheTimer
//
// Purpose: start the timer
//----------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------
// Return Value: none
//<---------------------------------------------------------------------
void on_startTheTimer();
//>---------------------------------------------------------------------
// Function: on_stopTheTimer
//
// Purpose: stop the timer
//----------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------
// Return Value: none
//<---------------------------------------------------------------------
void on_stopTheTimer();
signals:
void LabelChanged(int label, QString msg);
void ShowWindowChanged(bool show);
void startTheTimerChanged();
void stopTheTimerChanged();
private:
//>---------------------------------------------------------------------
// Function: timerEvent
//
// Purpose:
//----------------------------------------------------------------------
// Arguments:
//----------------------------------------------------------------------
// Return Value: none
//<---------------------------------------------------------------------
void timerEvent(QTimerEvent *event) override;
Ui::FileTransferDialog *ui;
int m_timerId;
int m_timeElapsedSec;
};
#endif // FILETRANSFERDIALOG_HPP

View File

@@ -0,0 +1,240 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>FileTransferDialog</class>
<widget class="QDialog" name="FileTransferDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>555</width>
<height>244</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(255, 255, 255);</string>
</property>
<widget class="QLabel" name="label1">
<property name="geometry">
<rect>
<x>20</x>
<y>60</y>
<width>47</width>
<height>13</height>
</rect>
</property>
<property name="font">
<font>
<family>Sans Serif</family>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>Name</string>
</property>
</widget>
<widget class="QLabel" name="FileName">
<property name="geometry">
<rect>
<x>150</x>
<y>54</y>
<width>401</width>
<height>21</height>
</rect>
</property>
<property name="font">
<font>
<family>Sans Serif</family>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>processing</string>
</property>
</widget>
<widget class="QLabel" name="Header">
<property name="geometry">
<rect>
<x>6</x>
<y>0</y>
<width>551</width>
<height>41</height>
</rect>
</property>
<property name="font">
<font>
<family>Sans Serif</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">background-color: qlineargradient(spread:pad, x1:1, y1:0.0340909, x2:0, y2:0.0113636, stop:0 rgba(0, 86, 255, 255), stop:1 rgba(255, 255, 255, 255));</string>
</property>
<property name="text">
<string>processing... please wait</string>
</property>
<property name="margin">
<number>9</number>
</property>
</widget>
<widget class="QLabel" name="label1_2">
<property name="geometry">
<rect>
<x>22</x>
<y>95</y>
<width>47</width>
<height>13</height>
</rect>
</property>
<property name="font">
<font>
<family>Sans Serif</family>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>From</string>
</property>
</widget>
<widget class="QLabel" name="label1_3">
<property name="geometry">
<rect>
<x>23</x>
<y>130</y>
<width>47</width>
<height>13</height>
</rect>
</property>
<property name="font">
<font>
<family>Sans Serif</family>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>To</string>
</property>
</widget>
<widget class="QLabel" name="label1_4">
<property name="geometry">
<rect>
<x>23</x>
<y>163</y>
<width>111</width>
<height>21</height>
</rect>
</property>
<property name="font">
<font>
<family>Sans Serif</family>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>Items Remaining</string>
</property>
</widget>
<widget class="QLabel" name="label1_5">
<property name="geometry">
<rect>
<x>23</x>
<y>199</y>
<width>91</width>
<height>21</height>
</rect>
</property>
<property name="font">
<font>
<family>Sans Serif</family>
<pointsize>10</pointsize>
</font>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="text">
<string>Time Elasped</string>
</property>
</widget>
<widget class="QLabel" name="From">
<property name="geometry">
<rect>
<x>150</x>
<y>88</y>
<width>401</width>
<height>21</height>
</rect>
</property>
<property name="font">
<font>
<family>Sans Serif</family>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>processing</string>
</property>
</widget>
<widget class="QLabel" name="To">
<property name="geometry">
<rect>
<x>150</x>
<y>125</y>
<width>401</width>
<height>21</height>
</rect>
</property>
<property name="font">
<font>
<family>Sans Serif</family>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>processing</string>
</property>
</widget>
<widget class="QLabel" name="ItemsRemain">
<property name="geometry">
<rect>
<x>150</x>
<y>162</y>
<width>401</width>
<height>21</height>
</rect>
</property>
<property name="font">
<font>
<family>Sans Serif</family>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>processing</string>
</property>
</widget>
<widget class="QLabel" name="TimeElapsed">
<property name="geometry">
<rect>
<x>150</x>
<y>197</y>
<width>401</width>
<height>21</height>
</rect>
</property>
<property name="font">
<font>
<family>Sans Serif</family>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>processing</string>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -0,0 +1,102 @@
#include "MainWindow.h"
#include "ui_mainwindow.h"
#include <QScreen>
#include <QRect>
#include <QtTest/QTest>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent),
ui(new Ui::MainWindow),
m_lastCursorPos(),
cursorXGoingEast(true),
cursorYGoingSouth(true)
{
ui->setupUi(this);
connect(this, SIGNAL(statusBoxChanged(QString)), this, SLOT(on_StatusBoxChanged(QString)));
timerId = startTimer(30000);
}
MainWindow::~MainWindow()
{
killTimer(timerId);
delete ui;
}
void MainWindow::updateStatusBox(std::string msg) {
emit statusBoxChanged(msg.c_str());
}
void MainWindow::on_StatusBoxChanged(QString msg) {
ui->statusBox->appendPlainText(msg);
}
void MainWindow::showEvent( QShowEvent* event )
{
QWidget::showEvent( event );
}
void MainWindow::timerEvent(QTimerEvent *)
{
QCursor cursor;
if (m_lastCursorPos.x() == cursor.pos().x() && m_lastCursorPos.y() == cursor.pos().y())
{
QScreen *screen = QGuiApplication::primaryScreen();
QRect screenGeometry = screen->geometry();
int height = screenGeometry.height();
int width = screenGeometry.width();
int newX = 0;
int newY = 0;
if (cursorXGoingEast)
newX = cursor.pos().x() + 50;
else
newX = cursor.pos().x() - 50;
if (cursorYGoingSouth)
newY = cursor.pos().y() + 50;
else
newY = cursor.pos().y() - 50;
if (newX > width)
{
newX = cursor.pos().x() - 50;
cursorXGoingEast = false;
}
else if (newX < 0)
{
newX = cursor.pos().x() + 50;
cursorXGoingEast = true;
}
if (newY > height)
{
newY = cursor.pos().y() - 50;
cursorYGoingSouth = false;
}
else if (newY < 0)
{
newY = cursor.pos().y() + 50;
cursorYGoingSouth = true;
}
m_lastCursorPos.setX(newX);
m_lastCursorPos.setY(newY);
cursor.setPos(newX, newY);
QTest::mouseClick(this, Qt::RightButton, Qt::NoModifier, QPoint(newX, newY));
QTest::mouseClick(this, Qt::RightButton, Qt::NoModifier, QPoint(newX, newY));
}
else
{
m_lastCursorPos = cursor.pos();
}
}

View File

@@ -0,0 +1,36 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
void updateStatusBox(std::string msg);
public slots:
void on_StatusBoxChanged(QString msg);
signals:
void statusBoxChanged(QString msg);
private:
void showEvent( QShowEvent* event ) override;
void timerEvent(QTimerEvent *event) override;
Ui::MainWindow *ui;
int timerId;
QPoint m_lastCursorPos;
bool cursorXGoingEast;
bool cursorYGoingSouth;
};
#endif // MAINWINDOW_H

View File

@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>858</width>
<height>694</height>
</rect>
</property>
<property name="windowTitle">
<string>HWIL Assistant</string>
</property>
<widget class="QWidget" name="centralwidget">
<widget class="QPlainTextEdit" name="statusBox">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>841</width>
<height>631</height>
</rect>
</property>
</widget>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>858</width>
<height>25</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -0,0 +1,43 @@
#include "LinuxProc.hpp"
#include "Exception.hpp"
#include "MainWindow.h"
#include "ErrorLog.hpp"
#include <QApplication>
#include <QMessageBox>
int main(int argc, char *argv[])
{
int ret = 0;
QApplication a(argc, argv);
try {
LinuxProc::Instance();
try {
LinuxProc::Instance().initialize();
} catch (Exception& e) {
MainWindow* pMainWindow = static_cast<MainWindow*>(&LinuxProc::Instance().getMainWindow());
if (pMainWindow != 0)
{
LinuxProc::Instance().getMainWindow().close();
}
ErrorLog::Instance().log(e.getMessage());
throw;
}
// this will loop indefinitely until we close the main GUI
ret = a.exec();
} catch (Exception& e) {
QMessageBox msgBox;
msgBox.setWindowTitle("Fatal Error");
msgBox.setText(e.getMessage(Exception::ERROR_MESSAGE_ONLY).c_str());
msgBox.exec();
}
return ret;
}