Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
barrier_gate
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
周彤
barrier_gate
Commits
48497380
Commit
48497380
authored
Dec 19, 2025
by
paopao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加日志
parent
619b0959
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
36 deletions
+29
-36
CMakeLists.txt
CMakeLists.txt
+1
-1
barrier_gate.cpp
src/barrier_gate.cpp
+23
-3
barrier_gate.hpp
src/barrier_gate.hpp
+5
-32
barrier_gate_log.h
src/barrier_gate_log.h
+0
-0
No files found.
CMakeLists.txt
View file @
48497380
...
...
@@ -74,7 +74,7 @@ install (TARGETS ${PROJECT_NAME}
set
(
MAJOR_VERSION 1
)
set
(
MINOR_VERSION 0
)
set
(
PATCH_VERSION
1
)
set
(
PATCH_VERSION
2
)
set
(
CPACK_PACKAGE_NAME
"ht-
${
PROJECT_NAME
}
"
)
set
(
CPACK_PACKAGE_VERSION_MAJOR
"
${
MAJOR_VERSION
}
"
)
...
...
src/barrier_gate.cpp
View file @
48497380
...
...
@@ -28,7 +28,7 @@ BarrierGateControl::BarrierGateControl(nlohmann::json& config,const std::map<int
,
uart_name_
(
config
[
"uart"
])
,
report_topic_
(
config
[
"report_topic"
])
,
control_topic_
(
config
[
"control_topic"
])
,
numbarrier_config_map
(
numbarrier_info_config_map
)
,
numbarrier_config_map
(
numbarrier_info_config_map
)
,
barrier_gate_Log
(
"Launch.ini"
)
{
init
();
}
...
...
@@ -38,13 +38,28 @@ BarrierGateControl::BarrierGateControl(nlohmann::json& config,const std::map<int
,
uart_name_
(
config
[
"uart"
])
,
report_topic_
(
config
[
"report_topic"
])
,
control_topic_
(
config
[
"control_topic"
])
,
numbarrier_config_map
(
numbarrier_info_config_map
)
,
numbarrier_config_map
(
numbarrier_info_config_map
)
,
barrier_gate_Log
(
"Launch.ini"
)
,
command_
(
command
)
{
RecordTimeLaunch
();
init
();
}
void
BarrierGateControl
::
RecordTimeLaunch
()
{
barrier_gate_Log
.
set_log_file
(
"RecordInfo.log"
);
if
(
!
barrier_gate_Log
.
exists
())
{
std
::
cout
<<
"INI文件不存在,正在创建新文件...
\n
"
;
if
(
!
barrier_gate_Log
.
create
())
{
std
::
cerr
<<
"创建INI文件失败
\n
"
;
return
;
}
}
}
void
BarrierGateControl
::
exec
()
{
__m_running
=
true
;
...
...
@@ -85,6 +100,7 @@ void BarrierGateControl::exec()
buffer
.
resize
(
containts
.
size
());
std
::
copy
(
containts
.
begin
(),
containts
.
end
(),
buffer
.
begin
());
std
::
cout
<<
"publish traffic light states: "
<<
containts
<<
std
::
endl
;
barrier_gate_Log
.
log
(
"publish traffic light states: "
+
containts
);
__m_status_puber
->
publish
(
buffer
);
}
}
...
...
@@ -104,7 +120,7 @@ void BarrierGateControl::exec()
if
(
crc
[
0
]
==
buffer
[
len
-
2
]
&&
crc
[
1
]
==
buffer
[
len
-
1
])
{
std
::
cout
<<
"crc check ok!"
<<
std
::
endl
;
barrier_gate_Log
.
log
(
"crc check ok!"
);
uint8_t
func_code
=
buffer
[
1
];
gate_code
=
(
buffer
[
len
-
4
]
<<
8
|
buffer
[
len
-
3
]);
if
(
func_code
==
0x03
)
...
...
@@ -121,6 +137,7 @@ void BarrierGateControl::exec()
else
{
std
::
cout
<<
"unknown func code: "
<<
(
int
)
func_code
<<
std
::
endl
;
barrier_gate_Log
.
log
(
"unknown func code:"
);
Exc_Barrier
(
0
,
gate_code
);
// 失败
}
}
...
...
@@ -159,6 +176,7 @@ void BarrierGateControl::init()
current_gate_
=
cvt_gate_status
(
command_
);
gate_control
(
0
,
current_gate_
);
std
::
cerr
<<
"init gate_control ..........."
<<
command_
<<
"current_gate_="
<<
current_gate_
<<
std
::
endl
;
barrier_gate_Log
.
log
(
"init gate_control ..........."
+
command_
+
"current_gate_="
+
std
::
to_string
(
current_gate_
));
}
void
BarrierGateControl
::
on_control_request
(
const
mqtt_dataio
::
subscriber_basic
::
DataBuffer
&
msg
)
...
...
@@ -181,6 +199,7 @@ void BarrierGateControl::on_control_request(const mqtt_dataio::subscriber_basic:
gate_control
(
0
,
gate
);
std
::
cout
<<
"change traffic light status from: "
<<
cvt_gate_status
(
current_gate_
)
<<
" to "
<<
cvt_gate_status
(
gate
)
<<
std
::
endl
;
barrier_gate_Log
.
log
(
"change traffic light status from: "
+
cvt_gate_status
(
current_gate_
)
+
" to "
+
cvt_gate_status
(
gate
));
current_gate_
=
gate
;
}
...
...
@@ -209,6 +228,7 @@ void BarrierGateControl::Exc_Barrier(int stateCode,uint16_t changeCode )
current_gate_
=
(
GateState
)
changeCode
;
std
::
string
barrier_gate_status
=
cvt_gate_status
(
changeCode
);
std
::
cout
<<
"gate code: "
<<
(
int
)
changeCode
<<
", barrier gate status: "
<<
barrier_gate_status
<<
std
::
endl
;
barrier_gate_Log
.
log
(
"gate code: "
+
std
::
to_string
((
int
)
changeCode
)
+
", barrier gate status: "
+
barrier_gate_status
);
return
;
}
//成功删除第一个值,取下一个值
...
...
src/barrier_gate.hpp
View file @
48497380
...
...
@@ -6,39 +6,8 @@
#include "uart/uart.hpp"
#include "3th-part/json.hpp"
#include <queue>
#include"barrier_gate_log.h"
struct
traffic_light_config
{
/* data */
uint16_t
id
;
std
::
string
type
;
std
::
vector
<
uint16_t
>
do_addr
;
std
::
vector
<
std
::
string
>
color
;
};
struct
roadside_info_config
{
std
::
string
id
;
std
::
string
topic
;
double
longitude
;
double
latitude
;
double
altitude
;
uint32_t
isLight
;
};
struct
traffic_light_status_config
{
/* data */
uint16_t
id
;
std
::
string
color
;
};
struct
traffic_mode_config
{
uint16_t
id
;
std
::
vector
<
traffic_light_status_config
>
lights
;
};
class
BarrierGateControl
...
...
@@ -90,6 +59,8 @@ private:
void
on_control_request
(
const
mqtt_dataio
::
subscriber_basic
::
DataBuffer
&
msg
);
void
RecordTimeLaunch
();
//记录日志
private
:
bool
__m_running
;
...
...
@@ -97,4 +68,6 @@ private:
uint16_t
__m_offset_do_addr
;
std
::
map
<
int
,
std
::
string
>
numbarrier_config_map
;
std
::
queue
<
BarrierGateControl
::
roadside_info_barrier
>
curExcBarrierQueue
;
Barrier_Gate_Log
barrier_gate_Log
;
//记录日志数据
};
src/barrier_gate_log.h
0 → 100644
View file @
48497380
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
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