Skip to content

Commit 38c01a9

Browse files
committed
[msvc] Fix startup of simulated charge points
1 parent 67b87df commit 38c01a9

File tree

2 files changed

+27
-6
lines changed

2 files changed

+27
-6
lines changed

src/chargepoint/ConnectorData.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ struct ConnectorData
4747
car_cable_capacity(0.f),
4848
car_ready(true),
4949
preparing_start(),
50-
fault_pending(false)
50+
fault_pending(false),
51+
unavailable_pending(false)
5152
{
5253
}
5354

src/launcher/CommandHandler.cpp

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -234,11 +234,7 @@ bool CommandHandler::startChargePoints(const rapidjson::Value& charge_points, bo
234234
// Build command line
235235
std::stringstream cmd;
236236
#ifndef _MSC_VER
237-
cmd << "./";
238-
#endif // _MSC_VER
239-
cmd << "chargepoint";
240-
#ifdef _MSC_VER
241-
cmd << ".exe";
237+
cmd << "./chargepoint";
242238
#endif // _MSC_VER
243239
cmd << " -w \"" << chargepoint_dir << "\"";
244240
cmd << " -t " << central_system;
@@ -249,10 +245,34 @@ bool CommandHandler::startChargePoints(const rapidjson::Value& charge_points, bo
249245
cmd << " -b " << m_broker_url;
250246
cmd << " -m " << max_current;
251247
cmd << " -i " << max_current_per_connector;
248+
#ifndef _MSC_VER
252249
cmd << " &" << std::endl;
250+
#endif // _MSC_VER
253251

254252
// Start charge point
253+
#ifndef _MSC_VER
255254
system(cmd.str().c_str());
255+
#else // _MSC_VER
256+
STARTUPINFO si;
257+
PROCESS_INFORMATION pi;
258+
259+
ZeroMemory(&si, sizeof(si));
260+
si.cb = sizeof(si);
261+
ZeroMemory(&pi, sizeof(pi));
262+
263+
CreateProcess("chargepoint.exe",
264+
const_cast<char*>(cmd.str().c_str()),
265+
nullptr,
266+
nullptr,
267+
FALSE,
268+
NORMAL_PRIORITY_CLASS,
269+
nullptr,
270+
nullptr,
271+
&si,
272+
&pi);
273+
CloseHandle(pi.hProcess);
274+
CloseHandle(pi.hThread);
275+
#endif // _MSC_VER
256276
total_started++;
257277
}
258278
}

0 commit comments

Comments
 (0)