diff --git a/cli/CommandLineInterface.cpp b/cli/CommandLineInterface.cpp index a2cc6d3..88bad12 100644 --- a/cli/CommandLineInterface.cpp +++ b/cli/CommandLineInterface.cpp @@ -25,6 +25,7 @@ #include "ModelManager.h" #include "PreviewerEngineLog.h" #include "VirtualScreen.h" +#include "CommandParser.h" using namespace std; @@ -135,6 +136,9 @@ void CommandLineInterface::ProcessCommandMessage(std::string message) const } string command = jsonData["command"].asString(); + if (CommandParser::GetInstance().IsStaticCard() && IsStaticIgnoreCmd(command)) { + return; + } std::unique_ptr commandLine = CommandLineFactory::CreateCommandLine(command, type, jsonData["args"], *socket); if (commandLine == nullptr) { @@ -266,3 +270,13 @@ void CommandLineInterface::CreatCommandToSendData(const string commandName, } commandLine->RunAndSendResultToManager(); } + +bool CommandLineInterface::IsStaticIgnoreCmd(const string cmd) const +{ + auto it = std::find(staticIgnoreCmd.begin(), staticIgnoreCmd.end(), cmd); + if (it != staticIgnoreCmd.end()) { + return false; + } else { + return true; + } +} diff --git a/cli/CommandLineInterface.h b/cli/CommandLineInterface.h index 0f7efef..072dde5 100644 --- a/cli/CommandLineInterface.h +++ b/cli/CommandLineInterface.h @@ -17,6 +17,7 @@ #define COMMANDLINEINTERFACE_H #include +#include #include "CommandLine.h" #include "LocalSocket.h" @@ -51,6 +52,8 @@ private: const static uint32_t MAX_COMMAND_LENGTH = 128; static bool isFirstWsSend; static bool isPipeConnected; + std::vector staticIgnoreCmd = { "ResolutionSwitch" }; + bool IsStaticIgnoreCmd(const std::string cmd) const; }; #endif // COMMANDLINEINTERFACE_H diff --git a/mock/VirtualScreen.cpp b/mock/VirtualScreen.cpp index 4225c76..53bcc54 100644 --- a/mock/VirtualScreen.cpp +++ b/mock/VirtualScreen.cpp @@ -34,6 +34,7 @@ bool VirtualScreen::isWebSocketListening = false; std::string VirtualScreen::webSocketPort = ""; std::chrono::system_clock::time_point VirtualScreen::startTime = std::chrono::system_clock::now(); +std::chrono::system_clock::time_point VirtualScreen::staticCardStartTime = std::chrono::system_clock::now(); bool VirtualScreen::isStartCount = true; bool VirtualScreen::isOutOfSeconds = false; @@ -272,6 +273,24 @@ bool VirtualScreen::JudgeStaticImage(const int duration) return true; } +bool VirtualScreen::StopSendStaticCardImage(const int duration) +{ + if (CommandParser::GetInstance().IsStaticCard()) { + static bool first = true; + if (first) { + first = false; + VirtualScreen::staticCardStartTime = std::chrono::system_clock::now(); + } + auto endTime = std::chrono::system_clock::now(); + int64_t timePassed = chrono::duration_cast(endTime - + VirtualScreen::staticCardStartTime).count(); + if (timePassed > duration) { + return true; + } + } + return false; +} + void VirtualScreen::RgbToJpg(unsigned char* data, const int32_t width, const int32_t height) { if (width < 1 || height < 1) { diff --git a/mock/VirtualScreen.h b/mock/VirtualScreen.h index c2096b7..e1f06c4 100644 --- a/mock/VirtualScreen.h +++ b/mock/VirtualScreen.h @@ -86,6 +86,7 @@ public: bool JudgeAndDropFrame(); void SetDropFrameFrequency(const int32_t& value); static bool JudgeStaticImage(const int duration); + static bool StopSendStaticCardImage(const int duration); void RgbToJpg(unsigned char* data, const int32_t width, const int32_t height); static uint32_t inputKeyCountPerMinute; static uint32_t inputMethodCountPerMinute; @@ -121,6 +122,7 @@ protected: int bluePos = 2; static std::chrono::system_clock::time_point startTime; + static std::chrono::system_clock::time_point staticCardStartTime; VirtualScreen::LoadDocType startLoadDoc = VirtualScreen::LoadDocType::INIT; std::chrono::system_clock::time_point startDropFrameTime; // record start drop frame time int dropFrameFrequency = 0; // save drop frame frequency diff --git a/mock/rich/VirtualScreenImpl.cpp b/mock/rich/VirtualScreenImpl.cpp index 34705ca..cc0aa3d 100644 --- a/mock/rich/VirtualScreenImpl.cpp +++ b/mock/rich/VirtualScreenImpl.cpp @@ -103,6 +103,9 @@ bool VirtualScreenImpl::LoadDocCallback(const void* data, bool VirtualScreenImpl::CallBack(const void* data, const size_t length, const int32_t width, const int32_t height) { + if (VirtualScreenImpl::GetInstance().StopSendStaticCardImage(STOP_SEND_CARD_DURATION_MS)) { + return false; + } if (VirtualScreenImpl::GetInstance().GetLoadDocFlag() < VirtualScreen::LoadDocType::FINISHED) { return false; } diff --git a/mock/rich/VirtualScreenImpl.h b/mock/rich/VirtualScreenImpl.h index 354b04d..e06dc94 100644 --- a/mock/rich/VirtualScreenImpl.h +++ b/mock/rich/VirtualScreenImpl.h @@ -55,6 +55,7 @@ private: uint64_t bufferSize; unsigned long long currentPos; static constexpr int SEND_IMG_DURATION_MS = 300; + static constexpr int STOP_SEND_CARD_DURATION_MS = 10000; uint8_t* loadDocTempBuffer; uint8_t* loadDocCopyBuffer; diff --git a/util/CommandParser.cpp b/util/CommandParser.cpp index 3f29a85..9a662c0 100644 --- a/util/CommandParser.cpp +++ b/util/CommandParser.cpp @@ -45,7 +45,8 @@ CommandParser::CommandParser() pages("main_pages"), containerSdkPath(""), isComponentMode(false), - abilityPath("") + abilityPath(""), + staticCard(false) { Register("-j", 1, "Launch the js app in ."); Register("-n", 1, "Set the js app name show on ."); @@ -81,6 +82,7 @@ CommandParser::CommandParser() Register("-hsp", 1, "Set container sdk path."); Register("-cpm", 1, "Set previewer start mode."); Register("-abp", 1, "Set abilityPath for debug."); + Register("-staticCard", 1, "Set card mode."); } CommandParser& CommandParser::GetInstance() @@ -118,7 +120,7 @@ bool CommandParser::IsCommandValid() partRet = partRet && IsColorModeValid() && IsOrientationValid() && IsWebSocketPortValid() && IsAceVersionValid(); partRet = partRet && IsScreenModeValid() && IsAppResourcePathValid(); partRet = partRet && IsProjectModelValid() && IsPagesValid() && IsContainerSdkPathValid(); - partRet = partRet && IsComponentModeValid() && IsAbilityPathValid(); + partRet = partRet && IsComponentModeValid() && IsAbilityPathValid() && IsStaticCardValid(); if (partRet) { return true; } @@ -273,6 +275,11 @@ string CommandParser::GetAbilityPath() const return abilityPath; } +bool CommandParser::IsStaticCard() const +{ + return staticCard; +} + bool CommandParser::IsDebugPortValid() { if (IsSet("p")) { @@ -824,4 +831,21 @@ bool CommandParser::IsAbilityPathValid() } abilityPath = path; return true; +} + +bool CommandParser::IsStaticCardValid() +{ + if (!IsSet("staticCard")) { + return true; + } + string val = Value("staticCard"); + if (val != "true" && val != "false") { + errorInfo = string("The staticCard argument unsupported."); + ELOG("Launch -staticCard parameters abnormal!"); + return false; + } + if (val == "true") { + staticCard = true; + } + return true; } \ No newline at end of file diff --git a/util/CommandParser.h b/util/CommandParser.h index 7527589..015dbd6 100644 --- a/util/CommandParser.h +++ b/util/CommandParser.h @@ -57,6 +57,7 @@ public: bool CheckParamInvalidity(std::string param, bool isNum); bool IsComponentMode() const; std::string GetAbilityPath() const; + bool IsStaticCard() const; private: CommandParser(); @@ -110,6 +111,7 @@ private: std::string regex4Str = "^(?:[a-zA-Z0-9-_./\\s]+)$"; bool isComponentMode; std::string abilityPath; + bool staticCard; bool IsDebugPortValid(); bool IsAppPathValid(); @@ -142,6 +144,7 @@ private: bool IsContainerSdkPathValid(); bool IsComponentModeValid(); bool IsAbilityPathValid(); + bool IsStaticCardValid(); std::string HelpText(); void ProcessingCommand(const std::vector& strs); };