Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
El Sayed, Nadim
ocpp-cp
Commits
aa2f2153
Commit
aa2f2153
authored
Sep 21, 2017
by
Gozutok, Recep
Browse files
Upload New File
parent
4a8f1ee5
Changes
1
Hide whitespace changes
Inline
Side-by-side
OPERATIONS/Goal/main.cpp
0 → 100644
View file @
aa2f2153
#include
"soapCentralSystemServiceSoapProxy.h"
// include the proxy declarations
#include
"soapreserveService.h"
#include
"soap.nsmap"
#include
<ctime>
#include
<thread>
#include
<mutex>
void
reserve
()
{
reserveService
server
;
std
::
cout
<<
"Starting Server ..."
<<
std
::
endl
;
while
(
server
.
run
(
8080
)
!=
SOAP_TCP_ERROR
)
server
.
soap_stream_fault
(
std
::
cerr
);
server
.
destroy
();
}
void
heartbeat
()
{
std
::
mutex
mtx
;
int
b
=
0
;
while
(
b
==
0
){
sleep
(
3
);
mtx
.
lock
();
CentralSystemServiceSoapProxy
service
;
std
::
cout
<<
"Starting client"
<<
std
::
endl
;
ns2__HeartbeatRequest
req
;
ns2__HeartbeatResponse
res
;
SOAP_ENV__Header
rec
;
rec
.
ns2__chargeBoxIdentity
;
rec
.
wsa5__MessageID
=
"file:///home/rgozutok/Belgeler/heartbeath/CentralSystemServiceSoap.Heartbeat.req.xml"
;
rec
.
wsa5__To
=
"http://130.149.159.42:9000/soap/CS?wsdl"
;
rec
.
wsa5__Action
=
"/Heartbeat"
;
service
.
soap_header
(
rec
.
ns2__chargeBoxIdentity
,
rec
.
wsa5__MessageID
,
rec
.
wsa5__RelatesTo
,
rec
.
wsa5__From
,
rec
.
wsa5__ReplyTo
,
rec
.
wsa5__FaultTo
,
rec
.
wsa5__To
,
rec
.
wsa5__Action
,
rec
.
chan__ChannelInstance
);
double
result
=
service
.
Heartbeat
(
"http://130.149.159.42:9000/soap/CS"
,
"/Heartbeat"
,
&
req
,
res
);
if
(
result
==
SOAP_OK
){
tm
*
ltm
=
localtime
(
&
res
.
currentTime
);
std
::
cout
<<
"Date: "
<<
ltm
->
tm_mday
<<
"/"
<<
1
+
ltm
->
tm_mon
<<
"/"
<<
1900
+
ltm
->
tm_year
<<
std
::
endl
;
std
::
cout
<<
"Time: "
<<
ltm
->
tm_hour
<<
":"
<<
ltm
->
tm_min
<<
":"
<<
1
+
ltm
->
tm_sec
<<
std
::
endl
;
}
mtx
.
unlock
();
}
}
void
authorize
()
{
CentralSystemServiceSoapProxy
service
;
ns2__AuthorizeRequest
req
;
ns2__AuthorizeResponse
res
;
SOAP_ENV__Header
rec
;
rec
.
ns2__chargeBoxIdentity
;
rec
.
wsa5__MessageID
=
"file:///home/rgozutok/Belgeler/c/CentralSystemServiceSoap.Authorize.req.xml"
;
rec
.
wsa5__To
=
"http://130.149.159.42:9000/soap/CS?wsdl"
;
rec
.
wsa5__Action
=
"/Authorize"
;
service
.
soap_header
(
rec
.
ns2__chargeBoxIdentity
,
rec
.
wsa5__MessageID
,
rec
.
wsa5__RelatesTo
,
rec
.
wsa5__From
,
rec
.
wsa5__ReplyTo
,
rec
.
wsa5__FaultTo
,
rec
.
wsa5__To
,
rec
.
wsa5__Action
,
rec
.
chan__ChannelInstance
);
double
result
=
service
.
Authorize
(
"http://130.149.159.42:9000/soap/CS"
,
"/Authorize"
,
&
req
,
res
);
if
(
result
==
SOAP_OK
)
{
std
::
cout
<<
"Yes the binding is working..."
<<
std
::
endl
;
if
(
res
.
idTagInfo
->
status
==
0
)
std
::
cout
<<
"Authorization is Accepted..."
<<
std
::
endl
;
if
(
res
.
idTagInfo
->
status
==
1
)
std
::
cout
<<
"Authorization is Blocked..."
<<
std
::
endl
;
if
(
res
.
idTagInfo
->
status
==
2
)
std
::
cout
<<
"Authorization is Expired..."
<<
std
::
endl
;
if
(
res
.
idTagInfo
->
status
==
3
)
std
::
cout
<<
"Authorization is Invalid..."
<<
std
::
endl
;
if
(
res
.
idTagInfo
->
status
==
4
)
std
::
cout
<<
"Authorization is ConcurrentTx..."
<<
std
::
endl
;
tm
*
ltm
=
localtime
(
res
.
idTagInfo
->
expiryDate
);
std
::
cout
<<
"Date: "
<<
ltm
->
tm_mday
<<
"/"
<<
1
+
ltm
->
tm_mon
<<
"/"
<<
1900
+
ltm
->
tm_year
<<
std
::
endl
;
std
::
cout
<<
"Time: "
<<
ltm
->
tm_hour
<<
":"
<<
ltm
->
tm_min
<<
":"
<<
1
+
ltm
->
tm_sec
<<
std
::
endl
;
}
}
int
main
()
{
CentralSystemServiceSoapProxy
service
;
std
::
thread
t1
(
authorize
);
t1
.
join
();
std
::
thread
t2
(
heartbeat
);
std
::
thread
t3
(
reserve
);
t3
.
join
();
t2
.
join
();
service
.
soap_stream_fault
(
std
::
cerr
);
service
.
destroy
();
}
int
reserveService
::
ReserveNow
(
ns1__ReserveNowRequest
*
ns1__reserveNowRequest
,
ns1__ReserveNowResponse
&
ns1__reserveNowResponse
)
{
ns1__ReserveNowResponse
res
;
res
.
status
=
ns1__ReserveStatus__Accepted
;
return
SOAP_OK
;
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment