diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1ff0c42 --- /dev/null +++ b/.gitattributes @@ -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 diff --git a/.gitignore b/.gitignore index 7f91721..73370fd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,26 +1,365 @@ -# ---> Windows -# Windows thumbnail cache files -Thumbs.db -Thumbs.db:encryptable -ehthumbs.db -ehthumbs_vista.db +## 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 -# Dump file -*.stackdump +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates -# Folder config file -[Dd]esktop.ini +/HWIL_Client/HWIL_Client/source/CommonLib/ -# Recycle Bin used on file shares -$RECYCLE.BIN/ +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs -# Windows Installer files -*.cab -*.msi -*.msix -*.msm -*.msp +# Mono auto generated files +mono_crash.* -# Windows shortcuts -*.lnk +# 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 + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# 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 \ No newline at end of file diff --git a/HWIL_Client/HWIL_Client.sln b/HWIL_Client/HWIL_Client.sln new file mode 100644 index 0000000..4f1643c --- /dev/null +++ b/HWIL_Client/HWIL_Client.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.33920.266 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HWIL_Client", "HWIL_Client\HWIL_Client.vcxproj", "{293D7BAA-6442-4DC6-8B0F-73E104F34016}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {293D7BAA-6442-4DC6-8B0F-73E104F34016}.Debug|x64.ActiveCfg = Debug|x64 + {293D7BAA-6442-4DC6-8B0F-73E104F34016}.Debug|x64.Build.0 = Debug|x64 + {293D7BAA-6442-4DC6-8B0F-73E104F34016}.Debug|x86.ActiveCfg = Debug|Win32 + {293D7BAA-6442-4DC6-8B0F-73E104F34016}.Debug|x86.Build.0 = Debug|Win32 + {293D7BAA-6442-4DC6-8B0F-73E104F34016}.Release|x64.ActiveCfg = Release|x64 + {293D7BAA-6442-4DC6-8B0F-73E104F34016}.Release|x64.Build.0 = Release|x64 + {293D7BAA-6442-4DC6-8B0F-73E104F34016}.Release|x86.ActiveCfg = Release|Win32 + {293D7BAA-6442-4DC6-8B0F-73E104F34016}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {F3E678A4-BA50-4E7F-AEAE-4013D9A3359E} + EndGlobalSection +EndGlobal diff --git a/HWIL_Client/HWIL_Client/HWIL_Client.vcxproj b/HWIL_Client/HWIL_Client/HWIL_Client.vcxproj new file mode 100644 index 0000000..3125ed7 --- /dev/null +++ b/HWIL_Client/HWIL_Client/HWIL_Client.vcxproj @@ -0,0 +1,269 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {293d7baa-6442-4dc6-8b0f-73e104f34016} + HWILClient + 10.0 + + + + Application + true + v143 + MultiByte + + + Application + false + v143 + true + MultiByte + + + Application + true + v143 + MultiByte + + + Application + false + v143 + true + MultiByte + + + + + + + + + + + + + + + + + + + + + true + $(ProjectDir)_$(PlatformShortName)\$(Configuration)\bin\ + $(ProjectDir)_$(PlatformShortName)\$(Configuration)\obj\ + + + false + $(ProjectDir)_$(PlatformShortName)\$(Configuration)\bin\ + $(ProjectDir)_$(PlatformShortName)\$(Configuration)\obj\ + + + true + $(ProjectDir)_$(PlatformShortName)\$(Configuration)\bin\ + $(ProjectDir)_$(PlatformShortName)\$(Configuration)\obj\ + + + false + $(ProjectDir)_$(PlatformShortName)\$(Configuration)\bin\ + $(ProjectDir)_$(PlatformShortName)\$(Configuration)\obj\ + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + .\source;.\source\Common;.\source\CommonLib\Comm;.\source\CommonLib\Exceptions;.\source\CommonLib\Lib;.\source\CommonLib\Lib\Util;.\source\CommonLib\Names;.\source\CommonLib\Proc;.\source\AutomationMessages + /MP /D "__FUNCTION_NAME__=__FUNCTION__\"()\"" %(AdditionalOptions) + 26812 + stdcpp17 + + + Console + true + Rpcrt4.lib;Shlwapi.lib;iphlpapi.lib;ws2_32.lib;%(AdditionalDependencies) + + + xcopy /y ".\config\config.ini" "$(OutDir)" + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + .\source;.\source\Common;.\source\CommonLib\Comm;.\source\CommonLib\Exceptions;.\source\CommonLib\Lib;.\source\CommonLib\Lib\Util;.\source\CommonLib\Names;.\source\CommonLib\Proc;.\source\AutomationMessages + /MP /D "__FUNCTION_NAME__=__FUNCTION__\"()\"" %(AdditionalOptions) + 26812 + stdcpp17 + + + Console + true + true + true + Rpcrt4.lib;Shlwapi.lib;iphlpapi.lib;ws2_32.lib;%(AdditionalDependencies) + + + xcopy /y ".\config\config.ini" "$(OutDir)" + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + .\source;.\source\Common;.\source\CommonLib\Comm;.\source\CommonLib\Exceptions;.\source\CommonLib\Lib;.\source\CommonLib\Lib\Util;.\source\CommonLib\Names;.\source\CommonLib\Proc;.\source\AutomationMessages + /MP /D "__FUNCTION_NAME__=__FUNCTION__\"()\"" %(AdditionalOptions) + 26812;4267 + stdcpp17 + + + Console + true + Rpcrt4.lib;Shlwapi.lib;iphlpapi.lib;ws2_32.lib;%(AdditionalDependencies) + + + xcopy /y ".\config\config.ini" "$(OutDir)" + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + stdcpp17 + .\source;.\source\Common;.\source\CommonLib\Comm;.\source\CommonLib\Exceptions;.\source\CommonLib\Lib;.\source\CommonLib\Lib\Util;.\source\CommonLib\Names;.\source\CommonLib\Proc;.\source\AutomationMessages + /MP /D "__FUNCTION_NAME__=__FUNCTION__\"()\"" %(AdditionalOptions) + 4267 + + + Console + true + true + true + Rpcrt4.lib;Shlwapi.lib;iphlpapi.lib;ws2_32.lib;%(AdditionalDependencies) + + + xcopy /y ".\config\config.ini" "$(OutDir)" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/HWIL_Client/HWIL_Client/HWIL_Client.vcxproj.filters b/HWIL_Client/HWIL_Client/HWIL_Client.vcxproj.filters new file mode 100644 index 0000000..cdc6335 --- /dev/null +++ b/HWIL_Client/HWIL_Client/HWIL_Client.vcxproj.filters @@ -0,0 +1,291 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + {453543d1-d1eb-49c5-b0e6-7d577b07e6e1} + + + {6950984b-9c13-462d-9b30-4c817645ca55} + + + {507ef9ec-cf39-41db-8640-49109d898fdb} + + + {82458dd4-3d67-40d4-8656-e131dd43dfca} + + + {19de6a93-a84e-4df9-a0fc-d49a027e37f1} + + + {16e2c28c-7a4f-4f42-8039-db2e955e3749} + + + {1959741c-94d2-46a5-94a8-f681b8a9b776} + + + {67b12f82-e19f-4772-9173-422182604f37} + + + {797b46a9-7c3f-4695-bb5d-4326e10b7dfb} + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files\AutomationMessages + + + Source Files\AutomationMessages + + + Source Files\AutomationMessages + + + Source Files\AutomationMessages + + + Source Files\AutomationMessages + + + Source Files\AutomationMessages + + + Source Files\AutomationMessages + + + Source Files\AutomationMessages + + + Source Files\AutomationMessages + + + Source Files\AutomationMessages + + + Source Files\AutomationMessages + + + Source Files\CommonLib\Comm + + + Source Files\CommonLib\Exceptions + + + Source Files\CommonLib\Exceptions + + + Source Files\CommonLib\Lib + + + Source Files\CommonLib\Lib + + + Source Files\CommonLib\Lib + + + Source Files\CommonLib\Lib + + + Source Files\CommonLib\Lib + + + Source Files\CommonLib\Lib + + + Source Files\CommonLib\Lib + + + Source Files\CommonLib\Lib + + + Source Files\CommonLib\Lib + + + Source Files\CommonLib\Lib + + + Source Files\CommonLib\Lib\Util + + + Source Files\CommonLib\Lib\Util + + + Source Files\CommonLib\Lib\Util + + + Source Files\CommonLib\Lib\Util + + + Source Files\CommonLib\Names + + + Source Files\CommonLib\Names + + + Source Files\CommonLib\Names + + + Source Files\CommonLib\Proc + + + Source Files + + + Source Files\Common + + + Source Files\Common + + + Source Files\CommonLib\Comm + + + Source Files\CommonLib\Comm + + + + + Source Files + + + Source Files + + + Source Files\AutomationMessages + + + Source Files\AutomationMessages + + + Source Files\AutomationMessages + + + Source Files\AutomationMessages + + + Source Files\AutomationMessages + + + Source Files\AutomationMessages + + + Source Files\AutomationMessages + + + Source Files\AutomationMessages + + + Source Files\AutomationMessages + + + Source Files\AutomationMessages + + + Source Files\AutomationMessages + + + Source Files\AutomationMessages + + + Source Files\CommonLib\Comm + + + Source Files\CommonLib\Exceptions + + + Source Files\CommonLib\Exceptions + + + Source Files\CommonLib\Lib + + + Source Files\CommonLib\Lib + + + Source Files\CommonLib\Lib + + + Source Files\CommonLib\Lib + + + Source Files\CommonLib\Lib + + + Source Files\CommonLib\Lib + + + Source Files\CommonLib\Lib + + + Source Files\CommonLib\Lib + + + Source Files\CommonLib\Lib + + + Source Files\CommonLib\Lib + + + Source Files\CommonLib\Lib + + + Source Files\CommonLib\Lib\Util + + + Source Files\CommonLib\Lib\Util + + + Source Files\CommonLib\Lib\Util + + + Source Files\CommonLib\Lib\Util + + + Source Files\CommonLib\Names + + + Source Files\CommonLib\Names + + + Source Files\CommonLib\Names + + + Source Files\CommonLib\Proc + + + Source Files + + + Source Files\Common + + + Source Files\Common + + + Source Files\CommonLib\Comm + + + Source Files\CommonLib\Comm + + + \ No newline at end of file diff --git a/HWIL_Client/HWIL_Client/config/config.ini b/HWIL_Client/HWIL_Client/config/config.ini new file mode 100644 index 0000000..5a9cfa2 --- /dev/null +++ b/HWIL_Client/HWIL_Client/config/config.ini @@ -0,0 +1,37 @@ +[GENERAL] +;ETB_REGEX_PATTERN = gucc.+ +ETB_REGEX_PATTERN = rmdu.+ + +HWIL_UDP_REMOTE_PORT = 44454 +HWIL_UDP_LOCAL_PORT = 44455 + +BASE_TEST_DATA_PATH = \\rrfs\projs\tsdc8\10911\DLe\test\ + +[SWDEV_PC] +;GUCC_COMPUTER = GUCC-SWDEV +GUCC_COMPUTER = rmdu0010260 +KWCC3_COMPUTER = KWCC3-SWDEV + +[SIXDOF_PC] +GUCC_COMPUTER = GUCC-6DOF +;GUCC_COMPUTER = asus-i7-6700k +KWCC3_COMPUTER = KWCC3-6DOF + +[VIDEO_PC] +GUCC_COMPUTER = GUCC-VCS +KWCC3-COMPUTER = TUTRKWCC-VCS + +UDP_REMOTE_PORT = 44452 +UDP_LOCAL_PORT = 44453 + +NUM_FRAMES_TO_GRAB = 3500 + +[ASG_PC] +GUCC_EXEC_COMPUTER = NEXEC3 +KWCC3_EXEC_COMPUTER = NEXEC2 + +GUCC_OGENA_COMPUTER = NOGEN3A +KWCC3_OGENA_COMPUTER = NOGEN2A + +KWCC3_OGENB_COMPUTER = NOGEN2B +KWCC3_OGENC_COMPUTER = NOGEN2C \ No newline at end of file diff --git a/HWIL_Client/HWIL_Client/main.cpp b/HWIL_Client/HWIL_Client/main.cpp new file mode 100644 index 0000000..81c330e --- /dev/null +++ b/HWIL_Client/HWIL_Client/main.cpp @@ -0,0 +1,27 @@ +#include +#include + +#include "HwilClient.hpp" +#include "TimeoutError.hpp" + +int main() +{ + try + { + //while (1) + // HwilClient::instance()->startingScenario(Constants::RemoteHosts::SWDEV_PC); + + while (1) + HwilClient::instance()->endingScenario(Constants::RemoteHosts::SWDEV_PC); + } + catch (Exception& e) + { + std::cout << e.getMessage() << std::endl; + } + + std::cout << "Press any key to quit: "; + + std::string str; + std::cin >> str; + return 0; +} \ No newline at end of file diff --git a/HWIL_Client/HWIL_Client/source/AutomationMessages/AutomationMsgHandler.cpp b/HWIL_Client/HWIL_Client/source/AutomationMessages/AutomationMsgHandler.cpp new file mode 100644 index 0000000..fd791cc --- /dev/null +++ b/HWIL_Client/HWIL_Client/source/AutomationMessages/AutomationMsgHandler.cpp @@ -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. +-------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include + +#include "AutomationMsgHandler.hpp" +#include "Exception.hpp" +#include "MessageHeader.hpp" +#include "MessageIDs.hpp" +#include "StringUtil.hpp" +#include "TransferGutsVideosCmdMessage.hpp" +#include "TransferAFileCmdMessage.hpp" +//----------------------------------------------------------------------------- + +AutomationMsgHandler::AutomationMsgHandler() +{ +} + +//----------------------------------------------------------------------------- + +AutomationMsgHandler::~AutomationMsgHandler(){} + +//----------------------------------------------------------------------------- + +AutomationMsgHandler& AutomationMsgHandler::instance() +{ + static AutomationMsgHandler handler; + return handler; +} + +//----------------------------------------------------------------------------- + +void AutomationMsgHandler::handleMsg(const unsigned char* pData, const unsigned int& id) +{ + bool selfThrown = false; + try + { + MessageIDs::MsgIds msgId = (MessageIDs::MsgIds)id; + + if (msgId == MessageIDs::SCENARIO_STARTED_CMD) + { + HandleKwScenarioStartedMessage(pData); + } + else if (msgId == MessageIDs::SCENARIO_STOPPED_CMD) + { + HandleKwScenarioStoppedMessage(pData); + } + else + { + std::stringstream ss; + ss << "unknown message id: " << id; + + selfThrown = true; + throw Exception (__FUNCTION_NAME__, ss.str()); + } + } + catch (Exception& e) + { + if (!selfThrown) + e.buildStackTrace(__FUNCTION_NAME__); + + throw e; + } +} + +//----------------------------------------------------------------------------- + +void AutomationMsgHandler::HandleKwScenarioStartedMessage(const unsigned char* pData) +{ + bool selfThrown = false; + + try { + + } + catch (Exception& e) + { + if (!selfThrown) + e.buildStackTrace(__FUNCTION_NAME__); + + throw e; + } +} + +//----------------------------------------------------------------------------- + +void AutomationMsgHandler::HandleKwScenarioStoppedMessage(const unsigned char* pData) +{ + bool selfThrown = false; + + try { + + } + catch (Exception& e) + { + if (!selfThrown) + e.buildStackTrace(__FUNCTION_NAME__); + + throw e; + } +} diff --git a/HWIL_Client/HWIL_Client/source/AutomationMessages/AutomationMsgHandler.hpp b/HWIL_Client/HWIL_Client/source/AutomationMessages/AutomationMsgHandler.hpp new file mode 100644 index 0000000..2bc9ea3 --- /dev/null +++ b/HWIL_Client/HWIL_Client/source/AutomationMessages/AutomationMsgHandler.hpp @@ -0,0 +1,92 @@ +// 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 + +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: HandleKwScenarioStartedMessage + // + // Purpose: + //---------------------------------------------------------------------------- + // Arguments: + //---------------------------------------------------------------------------- + // Return Value: + //---------------------------------------------------------------------------- + void HandleKwScenarioStartedMessage(const unsigned char* pData); + + //>--------------------------------------------------------------------------- + // Function: HandleKwScenarioStoppedMessage + // + // Purpose: + //---------------------------------------------------------------------------- + // Arguments: + //---------------------------------------------------------------------------- + // Return Value: + //---------------------------------------------------------------------------- + void HandleKwScenarioStoppedMessage(const unsigned char* pData); +}; + diff --git a/HWIL_Client/HWIL_Client/source/AutomationMessages/AutomationMsgParser.cpp b/HWIL_Client/HWIL_Client/source/AutomationMessages/AutomationMsgParser.cpp new file mode 100644 index 0000000..a789f68 --- /dev/null +++ b/HWIL_Client/HWIL_Client/source/AutomationMessages/AutomationMsgParser.cpp @@ -0,0 +1,179 @@ +// 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 +#include +#include +#include +#include + +#include "AutomationMsgParser.hpp" +#include "Exception.hpp" +#include "MessageHeader.hpp" +#include "MessageIDs.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::SCENARIO_STARTED_CMD); + msgIdsVec.push_back(MessageIDs::SCENARIO_STOPPED_CMD); + + msgIdsVec.push_back(MessageIDs::GENERIC_RSP); + + } catch (Exception& e) { + e.buildStackTrace(__FUNCTION_NAME__); + + 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(__FUNCTION_NAME__, 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(__FUNCTION_NAME__, ss.str()); + } + + if ( msgLen != numBytes) + { + std::stringstream ss; + ss << "Number of bytes received: " << numBytes << ". Expected only: " << msgLen; + + selfThrown = true; + throw Exception(__FUNCTION_NAME__, ss.str()); + } + + if (numBytes > header.GetHeaderLength()) + verifyDataFormat(pData, numBytes); + + *pMsgId = msgId; + } + catch (Exception& e) + { + if (!selfThrown) + e.buildStackTrace(__FUNCTION_NAME__); + + 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."; + + // want to make sure data size is at least 5 bytes + if (pTempDataStart+DATA_HEADER_LENGTH > pTempDataEnd) + { + selfThrown = true; + throw Exception(__FUNCTION_NAME__, ssError.str()); + } + + while (pTempDataStart < pTempDataEnd) + { + unsigned int dataSize = *(reinterpret_cast(pTempDataStart)); + + if (dataSize == 0) + { + selfThrown = true; + throw Exception(__FUNCTION_NAME__, ssError.str()); + + } + + pTempDataStart += DATA_HEADER_LENGTH + dataSize; + + if (pTempDataStart-1 > pTempDataEnd) + { + selfThrown = true; + throw Exception(__FUNCTION_NAME__, ssError.str()); + } + else if (pTempDataStart-1 == pTempDataEnd) + break; + } + } + catch (Exception& e) + { + if (!selfThrown) + e.buildStackTrace(__FUNCTION_NAME__); + + throw e; + } +} + diff --git a/HWIL_Client/HWIL_Client/source/AutomationMessages/AutomationMsgParser.hpp b/HWIL_Client/HWIL_Client/source/AutomationMessages/AutomationMsgParser.hpp new file mode 100644 index 0000000..bb2808b --- /dev/null +++ b/HWIL_Client/HWIL_Client/source/AutomationMessages/AutomationMsgParser.hpp @@ -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 + +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 msgIdsVec; +}; + diff --git a/HWIL_Client/HWIL_Client/source/AutomationMessages/GenericRspMessage.cpp b/HWIL_Client/HWIL_Client/source/AutomationMessages/GenericRspMessage.cpp new file mode 100644 index 0000000..adc14fd --- /dev/null +++ b/HWIL_Client/HWIL_Client/source/AutomationMessages/GenericRspMessage.cpp @@ -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. +-------------------------------------------------------------------------*/ +#include +#include +#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(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(__FUNCTION_NAME__); + 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(&m_messageStruct.wasCommandSuccessful), sizeof(m_messageStruct.wasCommandSuccessful), dataLen); + + // we want update total size of the entire message + m_header.SetMessageLength(static_cast(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(__FUNCTION_NAME__); + + throw e; + } +} + +//------------------------------------------------------------------------ + +std::string GenericRspMessage::ToString() const +{ + std::stringstream ss; + + ss << Message::ToString() + << "wasCommandSuccessful: " << m_messageStruct.wasCommandSuccessful << "\n" + << "\n"; + + return ss.str(); +} diff --git a/HWIL_Client/HWIL_Client/source/AutomationMessages/GenericRspMessage.hpp b/HWIL_Client/HWIL_Client/source/AutomationMessages/GenericRspMessage.hpp new file mode 100644 index 0000000..5d98105 --- /dev/null +++ b/HWIL_Client/HWIL_Client/source/AutomationMessages/GenericRspMessage.hpp @@ -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 ©); + + //>--------------------------------------------------------------------------- + // Function: ~GenericRspMessage + // + // Purpose: destructor + //---------------------------------------------------------------------------- + // Arguments: + //---------------------------------------------------------------------------- + // Return Value: + //---------------------------------------------------------------------------- + virtual ~GenericRspMessage(); + + //>--------------------------------------------------------------------------- + // Function: GetSuccessfulFlag + // + // Purpose: + //---------------------------------------------------------------------------- + // Arguments: + //---------------------------------------------------------------------------- + // Return Value: + //---------------------------------------------------------------------------- + bool GetSuccessfulFlag(){return static_cast(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; +}; diff --git a/HWIL_Client/HWIL_Client/source/AutomationMessages/KwScenarioStarted.cpp b/HWIL_Client/HWIL_Client/source/AutomationMessages/KwScenarioStarted.cpp new file mode 100644 index 0000000..9e1dc6e --- /dev/null +++ b/HWIL_Client/HWIL_Client/source/AutomationMessages/KwScenarioStarted.cpp @@ -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. +-------------------------------------------------------------------------*/ +#include +#include +#include "KwScenarioStarted.hpp" +#include "Exception.hpp" +#include "StringUtil.hpp" +#include "Proc.hpp" +#include "IniFile.hpp" +#include "GenericRspMessage.hpp" + +//------------------------------------------------------------------------ + +KwScenarioStarted::KwScenarioStarted(): + Message(MessageIDs::SCENARIO_STARTED_CMD, "SCENARIO_STARTED_CMD") +{ +} + +//------------------------------------------------------------------------ + +KwScenarioStarted::KwScenarioStarted(const KwScenarioStarted& copy) : + Message(copy) +{ +} + +//------------------------------------------------------------------------ + +KwScenarioStarted::~KwScenarioStarted() +{ +} + +//------------------------------------------------------------------------ + +Message* KwScenarioStarted::CloneSelf() +{ + KwScenarioStarted* pMsg = new KwScenarioStarted(*this); + return pMsg; +} + +//------------------------------------------------------------------------ + +void KwScenarioStarted::ExecuteMessage() +{ + try + { + + } + catch (Exception& e) + { + e.buildStackTrace(__FUNCTION_NAME__); + throw e; + } +} + +//------------------------------------------------------------------------ + +void KwScenarioStarted::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(dataLen)); + m_header.Format(pData); +} + +//------------------------------------------------------------------------ + +void KwScenarioStarted::ParseData(const unsigned char*) +{ +} + +//------------------------------------------------------------------------ + +std::string KwScenarioStarted::ToString() const +{ + std::stringstream ss; + + return ss.str(); +} diff --git a/HWIL_Client/HWIL_Client/source/AutomationMessages/KwScenarioStarted.hpp b/HWIL_Client/HWIL_Client/source/AutomationMessages/KwScenarioStarted.hpp new file mode 100644 index 0000000..f212d5f --- /dev/null +++ b/HWIL_Client/HWIL_Client/source/AutomationMessages/KwScenarioStarted.hpp @@ -0,0 +1,119 @@ +// 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 KwScenarioStarted : public Message +{ +public: + //>--------------------------------------------------------------------------- + // Function: KwScenarioStarted + // + // Purpose: constructor + //---------------------------------------------------------------------------- + // Arguments: + //---------------------------------------------------------------------------- + // Return Value: + //---------------------------------------------------------------------------- + KwScenarioStarted(); + + //>--------------------------------------------------------------------------- + // Function: KwScenarioStarted + // + // Purpose: copy constructor + //---------------------------------------------------------------------------- + // Arguments: + //---------------------------------------------------------------------------- + // Return Value: + //---------------------------------------------------------------------------- + KwScenarioStarted(const KwScenarioStarted ©); + + //>--------------------------------------------------------------------------- + // Function: ~KwScenarioStarted + // + // Purpose: destructor + //---------------------------------------------------------------------------- + // Arguments: + //---------------------------------------------------------------------------- + // Return Value: + //---------------------------------------------------------------------------- + virtual ~KwScenarioStarted(); + + //>--------------------------------------------------------------------------- + // 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 + KwScenarioStarted &operator=(const KwScenarioStarted &rhs); + +}; diff --git a/HWIL_Client/HWIL_Client/source/AutomationMessages/KwScenarioStopped.cpp b/HWIL_Client/HWIL_Client/source/AutomationMessages/KwScenarioStopped.cpp new file mode 100644 index 0000000..413b079 --- /dev/null +++ b/HWIL_Client/HWIL_Client/source/AutomationMessages/KwScenarioStopped.cpp @@ -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. +-------------------------------------------------------------------------*/ +#include +#include +#include "KwScenarioStopped.hpp" +#include "Exception.hpp" +#include "StringUtil.hpp" +#include "Proc.hpp" +#include "IniFile.hpp" +#include "GenericRspMessage.hpp" + +//------------------------------------------------------------------------ + +KwScenarioStopped::KwScenarioStopped(std::string testDataPath): + Message(MessageIDs::SCENARIO_STOPPED_CMD, "SCENARIO_STOPPED_CMD"), + m_testDataPath(testDataPath) +{ +} + +//------------------------------------------------------------------------ + +KwScenarioStopped::KwScenarioStopped(const KwScenarioStopped& copy) : + Message(copy) +{ +} + +//------------------------------------------------------------------------ + +KwScenarioStopped::~KwScenarioStopped() +{ +} + +//------------------------------------------------------------------------ + +Message* KwScenarioStopped::CloneSelf() +{ + KwScenarioStopped* pMsg = new KwScenarioStopped(*this); + return pMsg; +} + +//------------------------------------------------------------------------ + +void KwScenarioStopped::ExecuteMessage() +{ + try + { + } + catch (Exception& e) + { + e.buildStackTrace(__FUNCTION_NAME__); + throw e; + } +} + +//------------------------------------------------------------------------ + +void KwScenarioStopped::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(dataLen)); + m_header.Format(pData); +} + +//------------------------------------------------------------------------ + +void KwScenarioStopped::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(pTempDataStart), sizeOfData); + + } + catch (Exception& e) { + e.buildStackTrace(__FUNCTION_NAME__); + + throw e; + } +} + +//------------------------------------------------------------------------ + +std::string KwScenarioStopped::ToString() const +{ + std::stringstream ss; + + return ss.str(); +} diff --git a/HWIL_Client/HWIL_Client/source/AutomationMessages/KwScenarioStopped.hpp b/HWIL_Client/HWIL_Client/source/AutomationMessages/KwScenarioStopped.hpp new file mode 100644 index 0000000..58f597d --- /dev/null +++ b/HWIL_Client/HWIL_Client/source/AutomationMessages/KwScenarioStopped.hpp @@ -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 KwScenarioStopped : public Message +{ +public: + //>--------------------------------------------------------------------------- + // Function: KwScenarioStopped + // + // Purpose: constructor + //---------------------------------------------------------------------------- + // Arguments: + //---------------------------------------------------------------------------- + // Return Value: + //---------------------------------------------------------------------------- + KwScenarioStopped(std::string testDataPath); + + //>--------------------------------------------------------------------------- + // Function: KwScenarioStopped + // + // Purpose: copy constructor + //---------------------------------------------------------------------------- + // Arguments: + //---------------------------------------------------------------------------- + // Return Value: + //---------------------------------------------------------------------------- + KwScenarioStopped(const KwScenarioStopped ©); + + //>--------------------------------------------------------------------------- + // Function: ~KwScenarioStopped + // + // Purpose: destructor + //---------------------------------------------------------------------------- + // Arguments: + //---------------------------------------------------------------------------- + // Return Value: + //---------------------------------------------------------------------------- + virtual ~KwScenarioStopped(); + + //>--------------------------------------------------------------------------- + // 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 + KwScenarioStopped &operator=(const KwScenarioStopped &rhs); + + std::string m_testDataPath; + +}; diff --git a/HWIL_Client/HWIL_Client/source/AutomationMessages/Message.cpp b/HWIL_Client/HWIL_Client/source/AutomationMessages/Message.cpp new file mode 100644 index 0000000..4301338 --- /dev/null +++ b/HWIL_Client/HWIL_Client/source/AutomationMessages/Message.cpp @@ -0,0 +1,192 @@ +// 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 + +#include "Message.hpp" +#include "Exception.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(__FUNCTION_NAME__); + 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(__FUNCTION_NAME__); + throw e; + } +} + +//------------------------------------------------------------------------ + +void Message::SetMessageLength(const unsigned short& length) +{ + m_header.SetMessageLength(length); +} + +//------------------------------------------------------------------------ + +std::string Message::ToString() const +{ + std::stringstream ss; + ss << "Description: " << GetDescription() << "\n" << 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; + try + { + // make sure 4 bytes of header information is present + if (*pStartBuf + sizeOfDataHeader > pEndBuf) + { + selfThrown = true; + throw Exception(__FUNCTION_NAME__, 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(__FUNCTION_NAME__, ssError.str()); + } + } + catch (Exception& e) + { + if (!selfThrown) + e.buildStackTrace(__FUNCTION_NAME__); + + 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(*pStartBuf), &sizeOfDataBytes, sizeof(sizeOfDataBytes)); + *pStartBuf += sizeof(sizeOfDataBytes); + totalBytesInArray += sizeof(sizeOfDataBytes); + + // copy the data for this data item + memcpy(const_cast(*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(__FUNCTION_NAME__, ss.str()); + } + } + catch (Exception & e) { + if (!selfThrown) + e.buildStackTrace(__FUNCTION_NAME__); + + throw e; + } +} \ No newline at end of file diff --git a/HWIL_Client/HWIL_Client/source/AutomationMessages/Message.hpp b/HWIL_Client/HWIL_Client/source/AutomationMessages/Message.hpp new file mode 100644 index 0000000..0d761d0 --- /dev/null +++ b/HWIL_Client/HWIL_Client/source/AutomationMessages/Message.hpp @@ -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 +#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 ©); + + //>--------------------------------------------------------------------- + // 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: getStartOfNthDataItem + // + // Purpose: + // get the starting address of the nth 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; +}; diff --git a/HWIL_Client/HWIL_Client/source/AutomationMessages/MessageHeader.cpp b/HWIL_Client/HWIL_Client/source/AutomationMessages/MessageHeader.cpp new file mode 100644 index 0000000..3acdf74 --- /dev/null +++ b/HWIL_Client/HWIL_Client/source/AutomationMessages/MessageHeader.cpp @@ -0,0 +1,102 @@ +// 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 +#include +#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: " << m_headerStruct.messageId << "\n" << "msg len: " << m_headerStruct.messageLength << "\n"; + + return ss.str(); +} diff --git a/HWIL_Client/HWIL_Client/source/AutomationMessages/MessageHeader.hpp b/HWIL_Client/HWIL_Client/source/AutomationMessages/MessageHeader.hpp new file mode 100644 index 0000000..e978164 --- /dev/null +++ b/HWIL_Client/HWIL_Client/source/AutomationMessages/MessageHeader.hpp @@ -0,0 +1,161 @@ +// 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" + +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 ©); + + //>--------------------------------------------------------------------- + // 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; +}; diff --git a/HWIL_Client/HWIL_Client/source/AutomationMessages/MessageIDs.hpp b/HWIL_Client/HWIL_Client/source/AutomationMessages/MessageIDs.hpp new file mode 100644 index 0000000..3b0fecf --- /dev/null +++ b/HWIL_Client/HWIL_Client/source/AutomationMessages/MessageIDs.hpp @@ -0,0 +1,35 @@ +// 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 + { + TRANSFER_A_FILE_CMD = 0xCA001001, + TRANSFER_A_FOLDER_CMD = 0xCA001002, + TRANSFER_GUTS_VIDEOS_CMD = 0xCA001003, + MOVE_GUTS_VIDEOS_TO_SUB_FOLDER_CMD = 0xCA001004, + SCENARIO_STARTED_CMD = 0xCA001005, + SCENARIO_STOPPED_CMD = 0xCA001006, + + WAIT_FOR_COMPLETION_CMD = 0xCA002000, + + GENERIC_RSP = 0xCA002001 + }; +} diff --git a/HWIL_Client/HWIL_Client/source/AutomationMessages/MoveGutsVideosToSubFolderCmdMessage.cpp b/HWIL_Client/HWIL_Client/source/AutomationMessages/MoveGutsVideosToSubFolderCmdMessage.cpp new file mode 100644 index 0000000..ab86635 --- /dev/null +++ b/HWIL_Client/HWIL_Client/source/AutomationMessages/MoveGutsVideosToSubFolderCmdMessage.cpp @@ -0,0 +1,116 @@ +// 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 +#include +#include "MoveGutsVideosToSubFolderCmdMessage.hpp" +#include "Exception.hpp" +#include "StringUtil.hpp" + +//------------------------------------------------------------------------ + +MoveGutsVideosToSubFolderCmdMessage::MoveGutsVideosToSubFolderCmdMessage(std::string subFolder): + Message(MessageIDs::MOVE_GUTS_VIDEOS_TO_SUB_FOLDER_CMD, "MOVE_GUTS_VIDEOS_TO_SUB_FOLDER_CMD"), + m_subFolder(subFolder) +{ +} + +//------------------------------------------------------------------------ + +MoveGutsVideosToSubFolderCmdMessage::MoveGutsVideosToSubFolderCmdMessage(const MoveGutsVideosToSubFolderCmdMessage& copy) : + Message(copy), + m_subFolder(copy.m_subFolder) +{ +} + +//------------------------------------------------------------------------ + +MoveGutsVideosToSubFolderCmdMessage::~MoveGutsVideosToSubFolderCmdMessage() +{ +} + +//------------------------------------------------------------------------ + +Message* MoveGutsVideosToSubFolderCmdMessage::CloneSelf() +{ + MoveGutsVideosToSubFolderCmdMessage* pMsg = new MoveGutsVideosToSubFolderCmdMessage(*this); + return pMsg; +} + +//------------------------------------------------------------------------ + +void MoveGutsVideosToSubFolderCmdMessage::ExecuteMessage() +{ + try + { + + } + catch (Exception& e) + { + e.buildStackTrace(__FUNCTION_NAME__); + throw e; + } +} + +//------------------------------------------------------------------------ + +void MoveGutsVideosToSubFolderCmdMessage::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_subFolder.c_str(), m_subFolder.length(), dataLen); + + // we want update total size of the entire message + m_header.SetMessageLength(static_cast(dataLen)); + m_header.Format(pData); +} + +//------------------------------------------------------------------------ + +void MoveGutsVideosToSubFolderCmdMessage::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_subFolder = Util::Strings::ByteArrayToString(const_cast(pTempDataStart), sizeOfData); + + } catch (Exception& e) { + if (!selfThrown) + e.buildStackTrace(__FUNCTION_NAME__); + + throw e; + } +} + +//------------------------------------------------------------------------ + +std::string MoveGutsVideosToSubFolderCmdMessage::ToString() const +{ + std::stringstream ss; + + ss << "Subfolder name: " << m_subFolder; + + return ss.str(); +} diff --git a/HWIL_Client/HWIL_Client/source/AutomationMessages/MoveGutsVideosToSubFolderCmdMessage.hpp b/HWIL_Client/HWIL_Client/source/AutomationMessages/MoveGutsVideosToSubFolderCmdMessage.hpp new file mode 100644 index 0000000..ef121bd --- /dev/null +++ b/HWIL_Client/HWIL_Client/source/AutomationMessages/MoveGutsVideosToSubFolderCmdMessage.hpp @@ -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 MoveGutsVideosToSubFolderCmdMessage : public Message +{ +public: + //>--------------------------------------------------------------------------- + // Function: MoveGutsVideosToSubFolderCmdMessage + // + // Purpose: constructor + //---------------------------------------------------------------------------- + // Arguments: + //---------------------------------------------------------------------------- + // Return Value: + //---------------------------------------------------------------------------- + MoveGutsVideosToSubFolderCmdMessage(std::string subFolder = ""); + + //>--------------------------------------------------------------------------- + // Function: MoveGutsVideosToSubFolderCmdMessage + // + // Purpose: copy constructor + //---------------------------------------------------------------------------- + // Arguments: + //---------------------------------------------------------------------------- + // Return Value: + //---------------------------------------------------------------------------- + MoveGutsVideosToSubFolderCmdMessage(const MoveGutsVideosToSubFolderCmdMessage ©); + + //>--------------------------------------------------------------------------- + // Function: ~MoveGutsVideosToSubFolderCmdMessage + // + // Purpose: destructor + //---------------------------------------------------------------------------- + // Arguments: + //---------------------------------------------------------------------------- + // Return Value: + //---------------------------------------------------------------------------- + virtual ~MoveGutsVideosToSubFolderCmdMessage(); + + //>--------------------------------------------------------------------------- + // 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 + MoveGutsVideosToSubFolderCmdMessage &operator=(const MoveGutsVideosToSubFolderCmdMessage &rhs); + + std::string m_subFolder; +}; diff --git a/HWIL_Client/HWIL_Client/source/AutomationMessages/TransferAFileCmdMessage.cpp b/HWIL_Client/HWIL_Client/source/AutomationMessages/TransferAFileCmdMessage.cpp new file mode 100644 index 0000000..61d68f5 --- /dev/null +++ b/HWIL_Client/HWIL_Client/source/AutomationMessages/TransferAFileCmdMessage.cpp @@ -0,0 +1,136 @@ +// 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 +#include +#include "TransferAFileCmdMessage.hpp" +#include "Exception.hpp" +#include "StringUtil.hpp" + +//------------------------------------------------------------------------ + +TransferAFileCmdMessage::TransferAFileCmdMessage(std::string fromFile, std::string toFile, bool deleteSource): + Message(MessageIDs::TRANSFER_A_FILE_CMD, "TRANSFER_A_FILE_CMD"), + m_fromFile(fromFile), + m_toFile(toFile), + m_deleteSource(static_cast(deleteSource)) +{ +} + +//------------------------------------------------------------------------ + +TransferAFileCmdMessage::TransferAFileCmdMessage(const TransferAFileCmdMessage& copy) : + Message(copy), + m_fromFile(copy.m_fromFile), + m_toFile(copy.m_toFile), + m_deleteSource(copy.m_deleteSource) +{ +} + +//------------------------------------------------------------------------ + +TransferAFileCmdMessage::~TransferAFileCmdMessage() +{ +} + +//------------------------------------------------------------------------ + +Message* TransferAFileCmdMessage::CloneSelf() +{ + TransferAFileCmdMessage* pMsg = new TransferAFileCmdMessage(*this); + return pMsg; +} + +//------------------------------------------------------------------------ + +void TransferAFileCmdMessage::ExecuteMessage() +{ + try + { + + } + catch (Exception& e) + { + e.buildStackTrace(__FUNCTION_NAME__); + throw e; + } +} + +//------------------------------------------------------------------------ + +void TransferAFileCmdMessage::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_fromFile.c_str(), m_fromFile.length(), dataLen); + buildByteArray(&pTempDataStart, m_toFile.c_str(), m_toFile.length(), dataLen); + buildByteArray(&pTempDataStart, reinterpret_cast(&m_deleteSource), sizeof(m_deleteSource), dataLen); + + // we want update total size of the entire message + m_header.SetMessageLength(static_cast(dataLen)); + m_header.Format(pData); +} + +//------------------------------------------------------------------------ + +void TransferAFileCmdMessage::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_fromFile = Util::Strings::ByteArrayToString(const_cast(pTempDataStart), sizeOfData); + + sizeOfData = getNextDataItem(&pTempDataStart, pTempDataEnd, sizeOfData); + getNextDataItem(&pTempDataStart, pTempDataEnd, sizeOfData); + + sizeOfData = getNextDataItem(&pTempDataStart, pTempDataEnd, sizeOfData); + m_toFile = Util::Strings::ByteArrayToString(const_cast(pTempDataStart), sizeOfData); + + sizeOfData = getNextDataItem(&pTempDataStart, pTempDataEnd, sizeOfData); + getNextDataItem(&pTempDataStart, pTempDataEnd, sizeOfData); + + sizeOfData = getNextDataItem(&pTempDataStart, pTempDataEnd, sizeOfData); + // make sure byte number match between what we're expected and what we receive + compareByteNumber(sizeof(m_deleteSource), sizeOfData); + memcpy(&m_deleteSource, pTempDataStart, sizeOfData); + + } catch (Exception& e) { + if (!selfThrown) + e.buildStackTrace(__FUNCTION_NAME__); + + throw e; + } +} + +//------------------------------------------------------------------------ + +std::string TransferAFileCmdMessage::ToString() const +{ + std::stringstream ss; + + ss << "From file: " << m_fromFile << ". To file: " << m_toFile << ". Delete source: " << m_deleteSource; + + return ss.str(); +} diff --git a/HWIL_Client/HWIL_Client/source/AutomationMessages/TransferAFileCmdMessage.hpp b/HWIL_Client/HWIL_Client/source/AutomationMessages/TransferAFileCmdMessage.hpp new file mode 100644 index 0000000..aa7d19e --- /dev/null +++ b/HWIL_Client/HWIL_Client/source/AutomationMessages/TransferAFileCmdMessage.hpp @@ -0,0 +1,124 @@ +// 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 TransferAFileCmdMessage : public Message +{ +public: + //>--------------------------------------------------------------------------- + // Function: TransferAFileCmdMessage + // + // Purpose: constructor + //---------------------------------------------------------------------------- + // Arguments: + //---------------------------------------------------------------------------- + // Return Value: + //---------------------------------------------------------------------------- + TransferAFileCmdMessage(std::string fromFile = "", std::string toFile = "", bool deleteSource = false); + + //>--------------------------------------------------------------------------- + // Function: TransferAFileCmdMessage + // + // Purpose: copy constructor + //---------------------------------------------------------------------------- + // Arguments: + //---------------------------------------------------------------------------- + // Return Value: + //---------------------------------------------------------------------------- + TransferAFileCmdMessage(const TransferAFileCmdMessage ©); + + //>--------------------------------------------------------------------------- + // Function: ~TransferAFileCmdMessage + // + // Purpose: destructor + //---------------------------------------------------------------------------- + // Arguments: + //---------------------------------------------------------------------------- + // Return Value: + //---------------------------------------------------------------------------- + virtual ~TransferAFileCmdMessage(); + + //>--------------------------------------------------------------------------- + // 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 + TransferAFileCmdMessage &operator=(const TransferAFileCmdMessage &rhs); + + std::string m_fromFile; + + std::string m_toFile; + + unsigned int m_deleteSource; +}; diff --git a/HWIL_Client/HWIL_Client/source/AutomationMessages/TransferGutsVideosCmdMessage.cpp b/HWIL_Client/HWIL_Client/source/AutomationMessages/TransferGutsVideosCmdMessage.cpp new file mode 100644 index 0000000..8677b44 --- /dev/null +++ b/HWIL_Client/HWIL_Client/source/AutomationMessages/TransferGutsVideosCmdMessage.cpp @@ -0,0 +1,133 @@ +// 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 +#include +#include "TransferGutsVideosCmdMessage.hpp" +#include "Exception.hpp" +#include "StringUtil.hpp" + +//------------------------------------------------------------------------ + +TransferGutsVideosCmdMessage::TransferGutsVideosCmdMessage(std::string currentTestFolder, unsigned int transferEverything, unsigned int deleteSource): + Message(MessageIDs::TRANSFER_GUTS_VIDEOS_CMD, "TRANSFER_GUTS_VIDEOS_CMD"), + m_currentTestFolder(currentTestFolder), + m_transferEverything(transferEverything), + m_deleteSource(deleteSource) +{ +} + +//------------------------------------------------------------------------ + +TransferGutsVideosCmdMessage::TransferGutsVideosCmdMessage(const TransferGutsVideosCmdMessage& copy) : + Message(copy), + m_currentTestFolder(copy.m_currentTestFolder), + m_transferEverything(copy.m_transferEverything), + m_deleteSource(copy.m_deleteSource) +{ +} + +//------------------------------------------------------------------------ + +TransferGutsVideosCmdMessage::~TransferGutsVideosCmdMessage() +{ +} + +//------------------------------------------------------------------------ + +Message* TransferGutsVideosCmdMessage::CloneSelf() +{ + TransferGutsVideosCmdMessage* pMsg = new TransferGutsVideosCmdMessage(*this); + return pMsg; +} + +//------------------------------------------------------------------------ + +void TransferGutsVideosCmdMessage::ExecuteMessage() +{ + try + { + + } + catch (Exception& e) + { + e.buildStackTrace(__FUNCTION_NAME__); + throw e; + } +} + +//------------------------------------------------------------------------ + +void TransferGutsVideosCmdMessage::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_currentTestFolder.c_str(), m_currentTestFolder.length(), dataLen); + buildByteArray(&pTempDataStart, reinterpret_cast(&m_transferEverything), sizeof(m_transferEverything), dataLen); + buildByteArray(&pTempDataStart, reinterpret_cast(&m_deleteSource), sizeof(m_deleteSource), dataLen); + + // we want update total size of the entire message + m_header.SetMessageLength(static_cast(dataLen)); + m_header.Format(pData); +} + +//------------------------------------------------------------------------ + +void TransferGutsVideosCmdMessage::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 { + // get the address of the 1st data item + sizeOfData = getNextDataItem(&pTempDataStart, pTempDataEnd, sizeOfData); + m_currentTestFolder = Util::Strings::ByteArrayToString(const_cast(pTempDataStart), sizeOfData); + + sizeOfData = getNextDataItem(&pTempDataStart, pTempDataEnd, sizeOfData); + // make sure byte number match between what we're expected and what we receive + compareByteNumber(sizeof(m_transferEverything), sizeOfData); + memcpy(&m_transferEverything, pTempDataStart, sizeOfData); + + sizeOfData = getNextDataItem(&pTempDataStart, pTempDataEnd, sizeOfData); + // make sure byte number match between what we're expected and what we receive + compareByteNumber(sizeof(m_deleteSource), sizeOfData); + memcpy(&m_deleteSource, pTempDataStart, sizeOfData); + + } catch (Exception& e) { + if (!selfThrown) + e.buildStackTrace(__FUNCTION_NAME__); + + throw e; + } +} + +//------------------------------------------------------------------------ + +std::string TransferGutsVideosCmdMessage::ToString() const +{ + std::stringstream ss; + + ss << "current test folder: " << m_currentTestFolder << ". transfer everything: " << m_transferEverything << ". Delete source: " << m_deleteSource; + + return ss.str(); +} diff --git a/HWIL_Client/HWIL_Client/source/AutomationMessages/TransferGutsVideosCmdMessage.hpp b/HWIL_Client/HWIL_Client/source/AutomationMessages/TransferGutsVideosCmdMessage.hpp new file mode 100644 index 0000000..2114327 --- /dev/null +++ b/HWIL_Client/HWIL_Client/source/AutomationMessages/TransferGutsVideosCmdMessage.hpp @@ -0,0 +1,142 @@ +// 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 TransferGutsVideosCmdMessage : public Message +{ +public: + //>--------------------------------------------------------------------- + // Function: TransferGutsVideosCmdMessage + // + // Purpose: constructor + //---------------------------------------------------------------------- + // Arguments: + // + //---------------------------------------------------------------------- + // Return Value: none + //<--------------------------------------------------------------------- + TransferGutsVideosCmdMessage(std::string currentTestFolder, unsigned int transferEverything = 0, unsigned int deleteSource = 0); + + //>--------------------------------------------------------------------- + // Function: TransferGutsVideosCmdMessage + // + // Purpose: copy constructor + //---------------------------------------------------------------------- + // Arguments: + // + //---------------------------------------------------------------------- + // Return Value: none + //<--------------------------------------------------------------------- + TransferGutsVideosCmdMessage(const TransferGutsVideosCmdMessage ©); + + //>--------------------------------------------------------------------- + // Function: ~TransferGutsVideosCmdMessage + // + // Purpose: destructor + //---------------------------------------------------------------------- + // Arguments: + // + //---------------------------------------------------------------------- + // Return Value: none + //<--------------------------------------------------------------------- + virtual ~TransferGutsVideosCmdMessage(); + + //>--------------------------------------------------------------------- + // Function: ExecuteMessage + // + // Purpose: + //---------------------------------------------------------------------- + // Arguments: + // + //---------------------------------------------------------------------- + // Return Value: none + //<--------------------------------------------------------------------- + virtual void ExecuteMessage(); + + //>--------------------------------------------------------------------- + // Function: ToString + // + // Purpose: + //---------------------------------------------------------------------- + // Arguments: + // + //---------------------------------------------------------------------- + // Return Value: none + //<--------------------------------------------------------------------- + virtual std::string ToString() const; + +protected: + //>--------------------------------------------------------------------- + // Function: CloneSelf + // + // Purpose: + //---------------------------------------------------------------------- + // Arguments: + // + //---------------------------------------------------------------------- + // Return Value: none + //<--------------------------------------------------------------------- + virtual Message* CloneSelf(); + + //>--------------------------------------------------------------------- + // Function: FormatData + // + // Purpose: + //---------------------------------------------------------------------- + // Arguments: + // + //---------------------------------------------------------------------- + // Return Value: none + //<--------------------------------------------------------------------- + virtual void FormatData(unsigned char* pData); + + //>--------------------------------------------------------------------- + // Function: ParseData + // + // Purpose: + //---------------------------------------------------------------------- + // Arguments: + // + //---------------------------------------------------------------------- + // Return Value: none + //<--------------------------------------------------------------------- + virtual void ParseData(const unsigned char* pData); + + //>--------------------------------------------------------------------- + // Function: gatherInfo + // + // Purpose: + //---------------------------------------------------------------------- + // Arguments: + // + //---------------------------------------------------------------------- + // Return Value: none + //<--------------------------------------------------------------------- + void gatherInfo(); + +private: + // do not allow + TransferGutsVideosCmdMessage &operator=(const TransferGutsVideosCmdMessage &rhs); + + std::string m_currentTestFolder; + unsigned int m_transferEverything; + unsigned int m_deleteSource; +}; diff --git a/HWIL_Client/HWIL_Client/source/AutomationMessages/WaitForLastTaskCompletionCmdMessage.cpp b/HWIL_Client/HWIL_Client/source/AutomationMessages/WaitForLastTaskCompletionCmdMessage.cpp new file mode 100644 index 0000000..efa61ed --- /dev/null +++ b/HWIL_Client/HWIL_Client/source/AutomationMessages/WaitForLastTaskCompletionCmdMessage.cpp @@ -0,0 +1,88 @@ +// 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 +#include +#include "WaitForLastTaskCompletionCmdMessage.hpp" +#include "Exception.hpp" + +//------------------------------------------------------------------------ + +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 + { + + } + catch (Exception& e) + { + e.buildStackTrace(__FUNCTION_NAME__); + 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(); +} diff --git a/HWIL_Client/HWIL_Client/source/AutomationMessages/WaitForLastTaskCompletionCmdMessage.hpp b/HWIL_Client/HWIL_Client/source/AutomationMessages/WaitForLastTaskCompletionCmdMessage.hpp new file mode 100644 index 0000000..88a7ff7 --- /dev/null +++ b/HWIL_Client/HWIL_Client/source/AutomationMessages/WaitForLastTaskCompletionCmdMessage.hpp @@ -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 ©); + + //>--------------------------------------------------------------------------- + // 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); +}; diff --git a/HWIL_Client/HWIL_Client/source/Common/Constants.cpp b/HWIL_Client/HWIL_Client/source/Common/Constants.cpp new file mode 100644 index 0000000..84a43a9 --- /dev/null +++ b/HWIL_Client/HWIL_Client/source/Common/Constants.cpp @@ -0,0 +1,27 @@ +//>>******************************************************************** +// UNCLASSIFIED +// +// COPYRIGHT 2020 RAYTHEON COMPANY +// +// DESCRIPTION +// Class to be exported from this DLL for use in other assemblies +// +// $Revision: 1 $ +// +// REVISION HISTORY +// +// 1 4/23/2020 Duc Le +// - initial checkin +//<<******************************************************************** + +#include "Constants.hpp" + +//----------------------------------------------------------------------------- + +std::map Constants::EtbComputerNameMapping::computerMap = Constants::EtbComputerNameMapping::createMap(); +std::map Constants::KwCilComputerNameMapping::computerMap = Constants::KwCilComputerNameMapping::createMap(); +std::map Constants::ConfigSectionNameMapping::sectionMap = Constants::ConfigSectionNameMapping::createMap(); +std::map Constants::ConfigSectionToComputerKeyMapping::sectionToKeyMap = Constants::ConfigSectionToComputerKeyMapping::createMap(); + +//----------------------------------------------------------------------------- + diff --git a/HWIL_Client/HWIL_Client/source/Common/Constants.hpp b/HWIL_Client/HWIL_Client/source/Common/Constants.hpp new file mode 100644 index 0000000..03420ae --- /dev/null +++ b/HWIL_Client/HWIL_Client/source/Common/Constants.hpp @@ -0,0 +1,104 @@ +#pragma once + +#include +#include + +namespace Constants +{ + enum class TestPlatforms + { + ETB, + KWCIL, + NUM_PLATFORMS + }; + + enum class RemoteHosts + { + VIDEO_PC, + SWDEV_PC, + SIXDOF_PC, + ASGEXEC_PC, + ASG_OGEN1_PC, + ASG_OGEN2_PC, + ASG_OGEN3_PC, + NUM_REMOTE_HOSTS + }; + + enum class ConfigSections + { + VIDEO_PC, + SWDEV_PC, + SIXDOF_PC, + ASG_PC, + NUM_CONFIG_SECTIONS + }; + + struct EtbComputerNameMapping + { + static std::map createMap() + { + std::map map{ + {RemoteHosts::SWDEV_PC, "GUCC_COMPUTER"}, + {RemoteHosts::SIXDOF_PC, "GUCC_COMPUTER"}, + {RemoteHosts::ASGEXEC_PC, "GUCC_EXEC_COMPUTER"}, + {RemoteHosts::ASG_OGEN1_PC, "GUCC_OGENA_COMPUTER"}, + }; + + return map; + } + static std::map computerMap; + }; + + struct KwCilComputerNameMapping + { + static std::map createMap() + { + std::map map{ + {RemoteHosts::SWDEV_PC, "KWCC3_COMPUTER"}, + {RemoteHosts::SIXDOF_PC, "KWCC3_COMPUTER"}, + {RemoteHosts::ASGEXEC_PC, "KWCC3_EXEC_COMPUTER"}, + {RemoteHosts::ASG_OGEN1_PC, "KWCC3_OGENA_COMPUTER"}, + {RemoteHosts::ASG_OGEN2_PC, "KWCC3_OGENB_COMPUTER"}, + {RemoteHosts::ASG_OGEN3_PC, "KWCC3_OGENC_COMPUTER"}, + }; + + return map; + } + static std::map computerMap; + }; + + struct ConfigSectionNameMapping + { + static std::map createMap() + { + std::map map{ + {ConfigSections::SWDEV_PC, "SWDEV_PC"}, + {ConfigSections::SIXDOF_PC, "SIXDOF_PC"}, + {ConfigSections::ASG_PC, "ASG_PC"} + }; + + return map; + } + + static std::map sectionMap; + }; + + struct ConfigSectionToComputerKeyMapping + { + static std::map createMap() + { + std::map map{ + {RemoteHosts::SWDEV_PC, ConfigSections::SWDEV_PC}, + {RemoteHosts::SIXDOF_PC, ConfigSections::SIXDOF_PC}, + {RemoteHosts::ASGEXEC_PC, ConfigSections::ASG_PC}, + {RemoteHosts::ASG_OGEN1_PC, ConfigSections::ASG_PC}, + {RemoteHosts::ASG_OGEN2_PC, ConfigSections::ASG_PC}, + {RemoteHosts::ASG_OGEN3_PC, ConfigSections::ASG_PC} + }; + + return map; + } + + static std::map sectionToKeyMap; + }; +} diff --git a/HWIL_Client/HWIL_Client/source/Common/EventNames.cpp b/HWIL_Client/HWIL_Client/source/Common/EventNames.cpp new file mode 100644 index 0000000..6e31fa1 --- /dev/null +++ b/HWIL_Client/HWIL_Client/source/Common/EventNames.cpp @@ -0,0 +1,56 @@ +// 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 + +#include "EventNames.hpp" +#include "Exception.hpp" + +EventNames& EventNames::Instance() +{ + static EventNames names; + return names; +} + +//------------------------------------------------------------------------ + +EventNames::~EventNames() +{ +} + +//------------------------------------------------------------------------ + +EventNames::EventNames(): + m_nameMap() +{ + m_nameMap[GLOBAL_QUIT] = "GLOBAL_QUIT"; + m_nameMap[HWIL_QUIT_UDP_READ_EVENT] = "HWIL_QUIT_UDP_READ_EVENT"; +} + +//------------------------------------------------------------------------ + +std::string EventNames::operator[](EventNames::Names name) +{ + std::map::const_iterator it = m_nameMap.find(name); + if (it == m_nameMap.end()) + { + std::stringstream ss; + ss << "value " << name << " not found"; + throw Exception(__FUNCTION_NAME__,ss.str()); + } + + return it->second; +} diff --git a/HWIL_Client/HWIL_Client/source/Common/EventNames.hpp b/HWIL_Client/HWIL_Client/source/Common/EventNames.hpp new file mode 100644 index 0000000..6cd1fc7 --- /dev/null +++ b/HWIL_Client/HWIL_Client/source/Common/EventNames.hpp @@ -0,0 +1,44 @@ +// 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 +#include + +class EventNames +{ +public: + static EventNames& Instance(); + virtual ~EventNames(); + + enum Names + { + GLOBAL_QUIT, + HWIL_QUIT_UDP_READ_EVENT, + NUM_EVENTS + }; + + std::string operator[](EventNames::Names name); + +private: + // do not allow + EventNames(const EventNames &rhs); + EventNames& operator=(const EventNames& rhs) {}; + EventNames(); + + std::map m_nameMap; +}; diff --git a/HWIL_Client/HWIL_Client/source/HwilClient.cpp b/HWIL_Client/HWIL_Client/source/HwilClient.cpp new file mode 100644 index 0000000..b378b6d --- /dev/null +++ b/HWIL_Client/HWIL_Client/source/HwilClient.cpp @@ -0,0 +1,221 @@ +//>>******************************************************************** +// UNCLASSIFIED +// +// COPYRIGHT 2020 RAYTHEON COMPANY +// +// DESCRIPTION +// Class to be exported from this DLL for use in other assemblies +// +// $Revision: 1 $ +// +// REVISION HISTORY +// +// 1 4/23/2020 Duc Le +// - initial checkin +//<<******************************************************************** + +#include "HwilClient.hpp" +#include "HwilUdpSocket.hpp" +#include "Exception.hpp" + +#include "AutomationMsgParser.hpp" +#include "Message.hpp" +#include "GenericRspMessage.hpp" +#include "KwScenarioStarted.hpp" +#include "KwScenarioStopped.hpp" +#include "WaitForLastTaskCompletionCmdMessage.hpp" +#include "WinProc.hpp" +#include "IniFile.hpp" +#include "Timestamp.hpp" +#include "FileSystemUtil.hpp" + +#include +#include +//----------------------------------------------------------------------------- + +HwilClient* HwilClient::instance() +{ + static HwilClient* pClient = 0; + + try + { + if (pClient == 0) + { + pClient = new HwilClient(); + } + } + catch (Exception& ex) + { + ex.buildStackTrace(__FUNCTION_NAME__); + + throw ex; + } + + return pClient; +} + +//----------------------------------------------------------------------------- + +HwilClient::HwilClient(): + pUdpSocket_(0) +{ + try + { + pUdpSocket_ = new HwilUdpSocket(); + } + catch (Exception& ex) + { + ex.buildStackTrace(__FUNCTION_NAME__); + throw ex; + } +} + +//----------------------------------------------------------------------------- + +HwilClient::~HwilClient() +{ + if (pUdpSocket_ != 0) + delete pUdpSocket_; +} + +//----------------------------------------------------------------------------- + +void HwilClient::startingScenario(Constants::RemoteHosts remoteHost) +{ + try + { + KwScenarioStarted cmd; + GenericRspMessage rsp(false); + + SendCommandGetResponse(remoteHost, &cmd, &rsp); + + if (!rsp.GetSuccessfulFlag()) + { + throw Exception(__FUNCTION_NAME__, "Command failed to execute"); + } + } + catch (Exception & ex) + { + ex.buildStackTrace(__FUNCTION_NAME__); + + throw ex; + } +} + +//----------------------------------------------------------------------------- + +void HwilClient::endingScenario(Constants::RemoteHosts remoteHost) +{ + try + { + bool createFolderSuccess = false; + Timestamp ts; + std::string basePath = WinProc::Instance().getConfig().getString("GENERAL", "BASE_TEST_DATA_PATH"); + std::string relPath = ""; + + int runCount = 1; + std::stringstream testFolder; + std::string path = ""; + + std::string date; + std::string time; + + ts.GetCurrentDateTimeString(date, time, Timestamp::DateFormat::YYYYMM, Timestamp::TimeFormat::HHMMSS, "_"); + while (1) + { + testFolder.clear(); + testFolder.str(""); + testFolder << "run_" << std::setfill('0') << std::setw(3) << runCount++; + relPath = Util::FileSystem::BuildPath(date, testFolder.str()); + path = Util::FileSystem::BuildPath(basePath, relPath); + + if (!Util::FileSystem::IsDirectory(path)) + { + createFolderSuccess = Util::FileSystem::CreateFolder(path.c_str()); + break; + } + } + + if (createFolderSuccess) + { + KwScenarioStopped cmd(relPath); + GenericRspMessage rsp(false); + + SendCommandGetResponse(remoteHost, &cmd, &rsp); + + if (!rsp.GetSuccessfulFlag()) + { + throw Exception(__FUNCTION_NAME__, "Command failed to execute"); + } + } + } + catch (Exception& ex) + { + ex.buildStackTrace(__FUNCTION_NAME__); + + throw ex; + } +} + +//----------------------------------------------------------------------------- + +void HwilClient::waitForCompletion(Constants::RemoteHosts remoteHost, unsigned long timeoutMs) +{ + try + { + WaitForLastTaskCompletionCmdMessage cmd; + GenericRspMessage rsp(false); + + SendCommandGetResponse(remoteHost, &cmd, &rsp, timeoutMs); + + if (!rsp.GetSuccessfulFlag()) + { + throw Exception(__FUNCTION_NAME__, "Command failed to execute"); + } + } + catch (Exception & ex) + { + ex.buildStackTrace(__FUNCTION_NAME__); + + throw ex; + } +} + +//----------------------------------------------------------------------------- + +void HwilClient::SendCommandGetResponse(Constants::RemoteHosts remoteHost, Message* commandMsg, Message* rspMsg, unsigned long timeoutInMs) +{ + std::stringstream ss; + + try + { + // just need a buffer big enough for outgoing commands + const unsigned int BUF_SIZE = 1024; + + unsigned char data[BUF_SIZE]; + + commandMsg->Format(data); + + pUdpSocket_->write(remoteHost, data, commandMsg->GetEntireMessageLength()); + + unsigned int numBytesRead = 0; + unsigned char* data2; + pUdpSocket_->read(&data2, numBytesRead, timeoutInMs); + + unsigned int msgId = 0; + AutomationMsgParser::instance().parseMsg(data2, numBytesRead, &msgId); + + if (msgId != rspMsg->GetMessageID()) + { + ss << "Expected MSG ID: " << rspMsg << ". Received MSG ID: " << msgId; + throw Exception(__FUNCTION_NAME__, ss.str()); + } + + rspMsg->Parse(data2); + } + catch (Exception & ex) + { + ex.buildStackTrace(__FUNCTION_NAME__); + throw ex; + } +} \ No newline at end of file diff --git a/HWIL_Client/HWIL_Client/source/HwilClient.hpp b/HWIL_Client/HWIL_Client/source/HwilClient.hpp new file mode 100644 index 0000000..62c0c2f --- /dev/null +++ b/HWIL_Client/HWIL_Client/source/HwilClient.hpp @@ -0,0 +1,125 @@ +//>>******************************************************************** +// UNCLASSIFIED +// +// COPYRIGHT 2020 RAYTHEON COMPANY +// +// DESCRIPTION +// Class to be exported from this DLL for use in other assemblies +// +// $Revision: 1 $ +// +// REVISION HISTORY +// +// 1 4/23/2020 Duc Le +// - initial checkin +//<<******************************************************************** +#if !defined(HWILCLIENT_HPP) +#define HWILCLIENT_HPP + +#include +#include + +#include "Constants.hpp" + +class HwilUdpSocket; +class Message; + +class HwilClient +{ +public: + //>------------------------------------------------------------------------- + // Function: instance + // + // Purpose: make this class a singleton + //-------------------------------------------------------------------------- + // Arguments: + // remoteAddress - + // remotePort - + // localPort - + // bufferSizeInBytes - + // errorLogFileName - error log file + //-------------------------------------------------------------------------- + // Return Value: pointer to object + //<------------------------------------------------------------------------- + static HwilClient* instance(); + + //>------------------------------------------------------------------------- + // Function: HwilClient + // + // Purpose: destructor + //-------------------------------------------------------------------------- + // Arguments: + //-------------------------------------------------------------------------- + // Return Value: none + //<------------------------------------------------------------------------- + ~HwilClient(); + + //>------------------------------------------------------------------------- + // Function: startingScenario + // + // Purpose: + //-------------------------------------------------------------------------- + // Arguments: none + //-------------------------------------------------------------------------- + // Return Value: none + //<------------------------------------------------------------------------- + void startingScenario(Constants::RemoteHosts remoteHost); + + //>------------------------------------------------------------------------- + // Function: endingScenario + // + // Purpose: + //-------------------------------------------------------------------------- + // Arguments: none + //-------------------------------------------------------------------------- + // Return Value: none + //<------------------------------------------------------------------------- + void endingScenario(Constants::RemoteHosts remoteHost); + + //>------------------------------------------------------------------------- + // Function: waitForCompletion + // + // Purpose: + //-------------------------------------------------------------------------- + // Arguments: none + //-------------------------------------------------------------------------- + // Return Value: none + //<------------------------------------------------------------------------- + void waitForCompletion(Constants::RemoteHosts remoteHost, unsigned long timeoutMs = 0xFFFFFFFF); + +private: + //>------------------------------------------------------------------------- + // Function: HwilClient + // + // Purpose: constructor + //-------------------------------------------------------------------------- + // Arguments: + // remoteAddress - + // remotePort - + // localPort - + // bufferSizeInBytes - + // errorLogFileName - error log file + //-------------------------------------------------------------------------- + // Return Value: none + //<------------------------------------------------------------------------- + HwilClient(); + + //>------------------------------------------------------------------------- + // Function: SendCommandGetResponse + // + // Purpose: + //-------------------------------------------------------------------------- + // Arguments: none + //-------------------------------------------------------------------------- + // Return Value: none + //<------------------------------------------------------------------------- + void SendCommandGetResponse(Constants::RemoteHosts remoteHost, Message* commandMsg, Message* rspMsg, unsigned long timeoutInMs = 1000); + + // do not allow + HwilClient(const HwilClient& copy); + HwilClient& operator=(const HwilClient& rhs) { return *this; }; + + HwilUdpSocket* pUdpSocket_; +}; + +#endif //#if !defined(HWILCLIENT_HPP) diff --git a/HWIL_Client/HWIL_Client/source/HwilUdpSocket.cpp b/HWIL_Client/HWIL_Client/source/HwilUdpSocket.cpp new file mode 100644 index 0000000..3f01e59 --- /dev/null +++ b/HWIL_Client/HWIL_Client/source/HwilUdpSocket.cpp @@ -0,0 +1,338 @@ +//>>******************************************************************** +// UNCLASSIFIED +// +// COPYRIGHT 2020 RAYTHEON COMPANY +// +// DESCRIPTION +// Class to be exported from this DLL for use in other assemblies +// +// $Revision: 1 $ +// +// REVISION HISTORY +// +// 1 4/23/2020 Duc Le +// - initial checkin +//<<******************************************************************** + +#include "HwilUdpSocket.hpp" +#include "Exception.hpp" +#include "Constants.hpp" +#include "WinProc.hpp" +#include "IniFile.hpp" +#include "EventNames.hpp" +#include "NTEvent.hpp" +#include "NetworkUtil.hpp" + +#include // always make sure this is placed before any include +#include + +#include +#include +#include + +//----------------------------------------------------------------------------- + +HwilUdpSocket::HwilUdpSocket() : + socket_(INVALID_SOCKET), + timeOutWaitingForOverlappedEvent_(false) +{ + try + { + for (int i = 0; i < static_cast(Constants::RemoteHosts::NUM_REMOTE_HOSTS); i++) + { + memset(reinterpret_cast(&remoteSockInfo_[i]), 0, sizeof(remoteSockInfo_[i])); + } + + WSADATA wsa; + WORD version = MAKEWORD(2, 2); + + if (WSAStartup(version, &wsa) != 0) + { + throw Exception(__FUNCTION_NAME__, "WSAStartup() failed"); + } + + setupSocket(); + + int remotePort = WinProc::Instance().getConfig().getLong("GENERAL", "HWIL_UDP_REMOTE_PORT"); + + std::map::iterator it; + + std::map computerMap = WinProc::Instance().getComputerMap(); + for (it = computerMap.begin(); it != computerMap.end(); it++) + { + std::string section = Constants::ConfigSectionNameMapping::sectionMap[Constants::ConfigSectionToComputerKeyMapping::sectionToKeyMap[it->first]]; + std::string remoteHostAddress = WinProc::Instance().getConfig().getString(section, it->second); + remoteSockInfo_[static_cast(it->first)].sin_family = AF_INET; + try + { + inet_pton(remoteSockInfo_[static_cast(it->first)].sin_family, convertHostnameToIp(remoteHostAddress).c_str(), &(remoteSockInfo_[static_cast(it->first)].sin_addr)); + remoteSockInfo_[static_cast(it->first)].sin_port = htons(remotePort); + } + catch (Exception&) + { } + } + + ::ZeroMemory(&readOverlapped_, sizeof(WSAOVERLAPPED)); + readOverlapped_.hEvent = WSACreateEvent(); + + readBuffer_.len = BUF_SIZE; + readBuffer_.buf = data_; + } + catch (Exception& ex) + { + ex.buildStackTrace(__FUNCTION_NAME__); + + throw; + } +} + +//----------------------------------------------------------------------------- + +HwilUdpSocket::~HwilUdpSocket() +{ + if (socket_ != INVALID_SOCKET) + closesocket(socket_); +} + +//----------------------------------------------------------------------------- + +void HwilUdpSocket::setupSocket() +{ + try + { + if ((socket_ = socket(AF_INET, SOCK_DGRAM, 0)) == INVALID_SOCKET) + { + throw Exception(__FUNCTION_NAME__, "socket() failed"); + } + + localPort_ = WinProc::Instance().getConfig().getLong("GENERAL", "HWIL_UDP_LOCAL_PORT"); + + localSockInfo_.sin_family = AF_INET; + localSockInfo_.sin_addr.s_addr = INADDR_ANY; + localSockInfo_.sin_port = htons(localPort_); + + int set_option_on = 1; + // configure the socket to be bind to ip and port even if another process has already bound to the same ip and port + setsockopt(socket_, SOL_SOCKET, SO_REUSEADDR, (char*)&set_option_on, sizeof(set_option_on)); + + //Bind + if (bind(socket_, reinterpret_cast(&localSockInfo_), sizeof(localSockInfo_)) == SOCKET_ERROR) + { + throw Exception(__FUNCTION_NAME__, "bind() failed"); + } + } + catch (Exception & ex) + { + ex.buildStackTrace(__FUNCTION_NAME__); + + throw; + } +} + +//----------------------------------------------------------------------------- + +std::string HwilUdpSocket::convertHostnameToIp(std::string hostname) +{ + std::string ip = hostname; + // convert to dot address notation if needed + if (hostname.length() > 0 && !Util::Network::IsIpAddress(hostname)) + { + struct addrinfo hints = {}, * addrInfo; + char port_str[16] = {}; + + hints.ai_family = AF_INET; + hints.ai_socktype = SOCK_STREAM; + hints.ai_protocol = IPPROTO_TCP; + + int dwRetval = getaddrinfo(hostname.c_str(), port_str, &hints, &addrInfo); + + if (dwRetval != 0) + { + std::stringstream ss; + ss << "getaddrinfo() failed with error : " << WSAGetLastError(); + throw Exception(__FUNCTION_NAME__, ss.str()); + } + + struct sockaddr_in* ipv = (struct sockaddr_in*)addrInfo->ai_addr; + struct in_addr* addr = &(ipv->sin_addr); + + char ipstr[INET_ADDRSTRLEN]; + inet_ntop(addrInfo->ai_family, addr, ipstr, sizeof(ipstr)); + ip = std::string(ipstr); + } + + return ip; +} + +//----------------------------------------------------------------------------- + +void HwilUdpSocket::write(Constants::RemoteHosts host, unsigned char* pWriteBuf, unsigned int numBytes) +{ + try + { + write(host, reinterpret_cast(pWriteBuf), numBytes); + } + catch (Exception& e) + { + e.buildStackTrace(__FUNCTION_NAME__); + throw; + } +} + +//----------------------------------------------------------------------------- + +void HwilUdpSocket::write(Constants::RemoteHosts host, char* pWriteBuf, unsigned int numBytes) +{ + try + { + if (remoteSockInfo_[static_cast(host)].sin_addr.S_un.S_addr == 0) + { + std::string section = Constants::ConfigSectionNameMapping::sectionMap[Constants::ConfigSectionToComputerKeyMapping::sectionToKeyMap[host]]; + std::string remoteHostAddress = WinProc::Instance().getConfig().getString(section, WinProc::Instance().getComputerMap()[host]); + + throw Exception(__FUNCTION_NAME__, remoteHostAddress + " not available"); + } + + if (::sendto(socket_, pWriteBuf, numBytes, 0, (struct sockaddr*)&remoteSockInfo_[static_cast(host)], sizeof(remoteSockInfo_[static_cast(host)])) == SOCKET_ERROR) + { + throw Exception(__FUNCTION_NAME__, "sendto() failed"); + } + } + catch (Exception& e) + { + e.buildStackTrace(__FUNCTION_NAME__); + throw; + } +} + +//----------------------------------------------------------------------------- + +void HwilUdpSocket::read(unsigned char** pReadBuf, unsigned int& numBytesRead, DWORD readTimeOutMs) +{ + try + { + read(reinterpret_cast(pReadBuf), numBytesRead, readTimeOutMs); + } + catch (Exception& e) + { + e.buildStackTrace(__FUNCTION_NAME__); + throw; + } +} + +//----------------------------------------------------------------------------- + +void HwilUdpSocket::read(char** pReadBuf, unsigned int& numBytesRead, DWORD readTimeOutMs) +{ + enum + { + QUIT_READING, + READ_EVENT, + NUM_EVENT + }; + + HANDLE handles[NUM_EVENT]; + + try + { + handles[QUIT_READING] = WinProc::Instance().getEvent(EventNames::HWIL_QUIT_UDP_READ_EVENT).getHandle(); + handles[READ_EVENT] = readOverlapped_.hEvent; + + DWORD BytesRecvd = 0; + DWORD flags = 0; + int ret1; + int err; + DWORD ret2 = 0; + + if (timeOutWaitingForOverlappedEvent_) + { + ret1 = SOCKET_ERROR; + err = WSA_IO_PENDING; + timeOutWaitingForOverlappedEvent_ = false; + } + else + { + WSAResetEvent(readOverlapped_.hEvent); + + ret1 = ::WSARecv(socket_, + &readBuffer_, + 1, + &BytesRecvd, + &flags, + &readOverlapped_, + NULL); + + err = ::WSAGetLastError(); + } + + if (ret1 == SOCKET_ERROR) + { + switch (err) + { + case WSAEINVAL: + case WSA_IO_PENDING: + + ret2 = ::WaitForMultipleObjects(NUM_EVENT, handles, false, readTimeOutMs); + + if (ret2 == WAIT_TIMEOUT) + { + timeOutWaitingForOverlappedEvent_ = true; + throw Exception(__FUNCTION_NAME__, "WaitForMultipleObjects() timed out"); + } + else if ((ret2 - WAIT_OBJECT_0) == READ_EVENT) + { + if (!::WSAGetOverlappedResult(socket_, + &readOverlapped_, + &BytesRecvd, + FALSE, + &flags)) + { + int resultErr = ::WSAGetLastError(); + + switch (resultErr) + { + case WSA_OPERATION_ABORTED: + read(pReadBuf, numBytesRead, readTimeOutMs); + break; + case WSAECONNRESET: + case WSAECONNABORTED: // intentional fall-through + //setConnectionMade(false); + throw Exception(__FUNCTION_NAME__, "force closed"); + break; + + default: + break; + } + } + } + else if ((ret2 - WAIT_OBJECT_0) == QUIT_READING) + { + return; + } + + break; + + case WSAECONNRESET: + case WSAENOTSOCK: // intentional fall-through + case WSAENOTCONN: + case WSAENOBUFS: + throw Exception(__FUNCTION_NAME__, "connection closed"); + case WSAEMSGSIZE: + throw Exception(__FUNCTION_NAME__, "Receive Buffer is not large enough"); + break; + + case WSA_OPERATION_ABORTED: // fall through for now + break; + } + } + + numBytesRead = BytesRecvd; + *pReadBuf = data_; + } + catch (Exception & ex) + { + ex.buildStackTrace(__FUNCTION_NAME__); + + throw; + } +} \ No newline at end of file diff --git a/HWIL_Client/HWIL_Client/source/HwilUdpSocket.hpp b/HWIL_Client/HWIL_Client/source/HwilUdpSocket.hpp new file mode 100644 index 0000000..425c714 --- /dev/null +++ b/HWIL_Client/HWIL_Client/source/HwilUdpSocket.hpp @@ -0,0 +1,145 @@ +//>>******************************************************************** +// UNCLASSIFIED +// +// COPYRIGHT 2020 RAYTHEON COMPANY +// +// DESCRIPTION +// Class to be exported from this DLL for use in other assemblies +// +// $Revision: 1 $ +// +// REVISION HISTORY +// +// 1 4/23/2020 Duc Le +// - initial checkin +//<<******************************************************************** +#if !defined(HWILUDPSOCKET_HPP) +#define HWILUDPSOCKET_HPP + +#include +#include + +#include +#include + +#include "Constants.hpp" + +class HwilUdpSocket +{ +public: + //>------------------------------------------------------------------------- + // Function: HwilUdpSocket + // + // Purpose: constructor + //-------------------------------------------------------------------------- + // Arguments: + // remoteAddress - + // remotePort - + // localPort - + // bufferSizeInBytes - + // errorLogFileName - error log file + //-------------------------------------------------------------------------- + // Return Value: none + //<------------------------------------------------------------------------- + HwilUdpSocket(); + + //>------------------------------------------------------------------------- + // Function: HwilUdpSocket + // + // Purpose: destructor + //-------------------------------------------------------------------------- + // Arguments: + //-------------------------------------------------------------------------- + // Return Value: none + //<------------------------------------------------------------------------- + ~HwilUdpSocket(); + + //>------------------------------------------------------------------------- + // Function: write + // + // Purpose: + //-------------------------------------------------------------------------- + // Arguments: none + //-------------------------------------------------------------------------- + // Return Value: none + //<------------------------------------------------------------------------- + void write(Constants::RemoteHosts host, char* pWriteBuf, unsigned int numBytes); + + //>------------------------------------------------------------------------- + // Function: write + // + // Purpose: + //-------------------------------------------------------------------------- + // Arguments: none + //-------------------------------------------------------------------------- + // Return Value: none + //<------------------------------------------------------------------------- + void write(Constants::RemoteHosts host, unsigned char* pWriteBuf, unsigned int numBytes); + + //>------------------------------------------------------------------------- + // Function: read + // + // Purpose: + //-------------------------------------------------------------------------- + // Arguments: none + //-------------------------------------------------------------------------- + // Return Value: none + //<------------------------------------------------------------------------- + void read(char** pReadBuf, unsigned int& numBytesRead, DWORD readTimeOutMs = ULONG_MAX); + + //>------------------------------------------------------------------------- + // Function: read + // + // Purpose: + //-------------------------------------------------------------------------- + // Arguments: none + //-------------------------------------------------------------------------- + // Return Value: none + //<------------------------------------------------------------------------- + void read(unsigned char** pReadBuf, unsigned int& numBytesRead, DWORD readTimeOutMs = ULONG_MAX); + +protected: + //>------------------------------------------------------------------------- + // Function: setupSocket + // + // Purpose: + //-------------------------------------------------------------------------- + // Arguments: none + //-------------------------------------------------------------------------- + // Return Value: none + //<------------------------------------------------------------------------- + void setupSocket(); + + //>------------------------------------------------------------------------- + // Function: convertHostnameToIp + // + // Purpose: + //-------------------------------------------------------------------------- + // Arguments: none + //-------------------------------------------------------------------------- + // Return Value: none + //<------------------------------------------------------------------------- + std::string convertHostnameToIp(std::string hostname); + +private: + static const unsigned int BUF_SIZE = 1024; + + // do not allow + HwilUdpSocket(const HwilUdpSocket& copy); + HwilUdpSocket& operator=(const HwilUdpSocket& rhs) {}; + + std::string remoteAddress_; + int remotePort_; + int localPort_; + SOCKET socket_; + struct sockaddr_in localSockInfo_; + struct sockaddr_in remoteSockInfo_[static_cast(Constants::RemoteHosts::NUM_REMOTE_HOSTS)]; + + WSABUF readBuffer_; + WSAOVERLAPPED readOverlapped_; + bool timeOutWaitingForOverlappedEvent_; + + char data_[BUF_SIZE]; +}; + +#endif diff --git a/HWIL_Client/HWIL_Client/source/WinProc.cpp b/HWIL_Client/HWIL_Client/source/WinProc.cpp new file mode 100644 index 0000000..cdbecb5 --- /dev/null +++ b/HWIL_Client/HWIL_Client/source/WinProc.cpp @@ -0,0 +1,96 @@ +// 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 "WinProc.hpp" +#include "Exception.hpp" +#include "IniFile.hpp" +#include "Timestamp.hpp" +#include "ErrorLog.hpp" +#include "FileSystemUtil.hpp" +#include "Constants.hpp" +#include "MiscUtil.hpp" + +#include +#include + +//----------------------------------------------------------------------------- + +WinProc& WinProc::Instance() +{ + static WinProc proc; + return proc; +} + +//----------------------------------------------------------------------------- + +WinProc::WinProc() : + Proc() +{ + // 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 + // WinProc is the last static variables 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 { + std::string exePath = Util::FileSystem::ExtractDirectory(Util::FileSystem::GetExePathAndFilename().c_str()); + + std::string configFilePath = Util::FileSystem::BuildPath(exePath, "config.ini"); + + m_iniFile = new IniFile(configFilePath); + + m_computerMap = Constants::KwCilComputerNameMapping::computerMap; + std::string etbRegexPattern = m_iniFile->getString("GENERAL", "ETB_REGEX_PATTERN"); + std::string computerName = Util::Misc::GetComputerName(); + // is ETB + if (std::regex_match(computerName, std::regex(etbRegexPattern, std::regex_constants::icase))) + { + m_computerMap = Constants::EtbComputerNameMapping::computerMap; + } + + std::string logPath = Util::FileSystem::BuildPath(exePath, "Output"); + + Util::FileSystem::CreateFolder(logPath); + + Util::FileSystem::CleanUpLogs(logPath, ".+\\.txt"); + + std::stringstream ss; + std::string date; + std::string time; + + Timestamp::GetCurrentDateTimeString(date, time, Timestamp::DateFormat::YYYYMMDD, Timestamp::TimeFormat::HHMMSS, "_"); + + ss << date << "_" << time << "_log.txt"; + + ErrorLog::Instance(Util::FileSystem::BuildPath(logPath, ss.str())); + + } + catch (Exception& e) { + e.buildStackTrace(__FUNCTION_NAME__); + throw; + } +} + +//----------------------------------------------------------------------------- + +WinProc::~WinProc() +{ + +} diff --git a/HWIL_Client/HWIL_Client/source/WinProc.hpp b/HWIL_Client/HWIL_Client/source/WinProc.hpp new file mode 100644 index 0000000..218f365 --- /dev/null +++ b/HWIL_Client/HWIL_Client/source/WinProc.hpp @@ -0,0 +1,88 @@ +// 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 "Constants.hpp" + +class IniFile; + +class WinProc : public Proc +{ + +public: + //>--------------------------------------------------------------------------- + // Function: instance + // + // Purpose: singleton + //---------------------------------------------------------------------------- + // Arguments: + //---------------------------------------------------------------------------- + // Return Value: + //---------------------------------------------------------------------------- + static WinProc& Instance(); + + //>--------------------------------------------------------------------------- + // Function: getConfig + // + // Purpose: + //---------------------------------------------------------------------------- + // Arguments: + //---------------------------------------------------------------------------- + // Return Value: + //---------------------------------------------------------------------------- + IniFile& getConfig(){return *m_iniFile;}; + + //>--------------------------------------------------------------------------- + // Function: ~Proc + // + // Purpose: Destroyer + //---------------------------------------------------------------------------- + // Arguments: + //---------------------------------------------------------------------------- + // Return Value: + //---------------------------------------------------------------------------- + ~WinProc(); + + //>--------------------------------------------------------------------------- + // Function: getComputerMap + // + // Purpose: + //---------------------------------------------------------------------------- + // Arguments: + //---------------------------------------------------------------------------- + // Return Value: + std::map getComputerMap() { return m_computerMap; } + +private: + //>--------------------------------------------------------------------------- + // Function: Proc + // + // Purpose: Ctor + //---------------------------------------------------------------------------- + // Arguments: + //---------------------------------------------------------------------------- + // Return Value: + //---------------------------------------------------------------------------- + WinProc(); + + IniFile* m_iniFile; + std::map m_computerMap; +}; + +#endif