Files
openvehicle-api/examples/open_trunk_example/open_trunk_app/trunk_example.cpp
2026-03-27 14:12:49 +01:00

71 lines
1.7 KiB
C++

/********************************************************************************
* Copyright (c) 2025-2026 ZF Friedrichshafen AG
*
* This program and the accompanying materials are made available under the
* terms of the Apache License Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/
#include <iostream>
#include <cstdlib> // for std::strtol
#include "trunk_application.h"
#include "console.h"
#if defined(_WIN32) && defined(_UNICODE)
extern "C" int wmain(int argc, wchar_t* argv[])
{
uint32_t uiInstance = 0;
if (argc < 2)
{
std::cout << "Missing instance number to connect to, '0' will run as standalone application" << std::endl;
return 1;
}
try
{
uiInstance = std::stoi(argv[1]);
}
catch (const std::exception& )
{
uiInstance = 0;
}
#else
extern "C" int main(int argc, char* argv[])
{
uint32_t uiInstance = 0;
if (argc < 2)
{
std::cout << "Missing instance number to connect to, '0' will run as standalone application" << std::endl;
return 1;
}
try
{
uiInstance = std::stoi(argv[1]);
}
catch (const std::exception& )
{
uiInstance = 0;
}
#endif
CTrunkControl appobj;
if (!appobj.Initialize(uiInstance))
{
std::cout << "ERROR: Failed to initialize application control." << std::endl;
return 0;
}
CConsole visual_obj;
visual_obj.PrintHeader(uiInstance);
visual_obj.PrepareDataConsumers();
appobj.SetRunningMode();
visual_obj.RunUntilBreak();
visual_obj.ResetSignals();
appobj.Shutdown();
return 0;
}