|
@@ -1781,11 +1781,11 @@ int CYAServerDlg::init_traffic_lights(int light_id)
|
|
|
char sql[LENGTH_SQL] = {0};
|
|
|
if (light_id == 0)
|
|
|
{
|
|
|
- sprintf_s(sql, "select light_id,ip,x,y,z,name,label,map_id,area_id,section_id,ctrl_reader_id,group_id,port,device_type_id from dat_light where state = 0;");
|
|
|
+ sprintf_s(sql, "select light_id,ip,x,y,z,name,label,map_id,area_id,section_id,ctrl_reader_id,group_id,port,device_type_id,stream from dat_light where state = 0;");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- sprintf_s(sql, "select light_id,ip,x,y,z,name,label,map_id,area_id,section_id,ctrl_reader_id,group_id,port,device_type_id from dat_light where state = 0 and light_id = %d;",light_id);
|
|
|
+ sprintf_s(sql, "select light_id,ip,x,y,z,name,label,map_id,area_id,section_id,ctrl_reader_id,group_id,port,device_type_id,stream from dat_light where state = 0 and light_id = %d;",light_id);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -1830,6 +1830,7 @@ int CYAServerDlg::init_traffic_lights(int light_id)
|
|
|
pLight->m_nLightsGroupID = atoi(pRow[11]);
|
|
|
pLight->m_nPort = atoi(pRow[12]);
|
|
|
pLight->device_type_id = atoi(pRow[13]);
|
|
|
+ pLight->m_nStream = atoi(pRow[14]);
|
|
|
|
|
|
MapInfoMap::iterator it_map = mp_map_list.find(pLight->m_nMapID);
|
|
|
if (it_map != mp_map_list.end())
|
|
@@ -1923,13 +1924,12 @@ int CYAServerDlg::init_section(int section_id)
|
|
|
pSection->init_border(pSection->m_strPath);
|
|
|
}
|
|
|
|
|
|
- MapInfoMap::iterator it_map = mp_map_list.find(pSection->m_nMapId);
|
|
|
- if (it_map != mp_map_list.end())
|
|
|
+ LightMap::iterator it_light = mp_light_list.begin();
|
|
|
+ for (;it_light != mp_light_list.end();++it_light)
|
|
|
{
|
|
|
- SectionMap::iterator it_section = it_map->second->map_section_list.find(pSection->m_nID);
|
|
|
- if (it_section == it_map->second->map_section_list.end())
|
|
|
+ if (it_light->second->m_nSectionID == pSection->m_nID)
|
|
|
{
|
|
|
- it_map->second->map_section_list.insert(make_pair(pSection->m_nID,pSection));
|
|
|
+ pSection->mp_light_list.insert(make_pair(it_light->second->m_nID,it_light->second));
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1948,6 +1948,15 @@ int CYAServerDlg::init_section(int section_id)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ MapInfoMap::iterator it_map = mp_map_list.find(pSection->m_nMapId);
|
|
|
+ if (it_map != mp_map_list.end())
|
|
|
+ {
|
|
|
+ SectionMap::iterator it_section = it_map->second->map_section_list.find(pSection->m_nID);
|
|
|
+ if (it_section == it_map->second->map_section_list.end())
|
|
|
+ {
|
|
|
+ it_map->second->map_section_list.insert(make_pair(pSection->m_nID,pSection));
|
|
|
+ }
|
|
|
+ }
|
|
|
nRow++;
|
|
|
}
|
|
|
|
|
@@ -1984,11 +1993,11 @@ int CYAServerDlg::init_light_group(int group_id /*= 0*/)
|
|
|
char sql[LENGTH_SQL] = {0};
|
|
|
if (group_id == 0)
|
|
|
{
|
|
|
- sprintf_s(sql,"select group_id,name,label from dat_lights_group where state = 0;");
|
|
|
+ sprintf_s(sql,"select lights_group_id,name,label,state,section_id from dat_lights_group where state = 0;");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- sprintf_s(sql,"select group_id,name,label from dat_lights_group where state = 0 and group_id = %d;",group_id);
|
|
|
+ sprintf_s(sql,"select lights_group_id,name,label,state,section_id from dat_lights_group where state = 0 and group_id = %d;",group_id);
|
|
|
}
|
|
|
|
|
|
MYSQL_RES* pRes = NULL;
|
|
@@ -2022,9 +2031,10 @@ int CYAServerDlg::init_light_group(int group_id /*= 0*/)
|
|
|
}
|
|
|
|
|
|
pLightGroup->m_nID = nGroupId;
|
|
|
- pLightGroup->m_nState = 0;
|
|
|
pLightGroup->m_strName = pRow[1];
|
|
|
pLightGroup->m_strLabel = pRow[2];
|
|
|
+ pLightGroup->m_nState = atoi(pRow[3]);
|
|
|
+ pLightGroup->m_nSectionId = atoi(pRow[4]);
|
|
|
|
|
|
LightMap::iterator it_light = mp_light_list.begin();
|
|
|
for (;it_light != mp_light_list.end();++it_light)
|
|
@@ -2036,6 +2046,21 @@ int CYAServerDlg::init_light_group(int group_id /*= 0*/)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ SectionMap::iterator it_section = mp_section_list.find(pLightGroup->m_nSectionId);
|
|
|
+ if (it_section != mp_section_list.end())
|
|
|
+ {
|
|
|
+ MapInfoMap::iterator it_map = mp_map_list.find(it_section->second->m_nMapId);
|
|
|
+ if (it_map != mp_map_list.end())
|
|
|
+ {
|
|
|
+ LightGroupMap::iterator it_light_group = it_map->second->map_light_group_list.find(pLightGroup->m_nID);
|
|
|
+ if (it_light_group == it_map->second->map_light_group_list.end())
|
|
|
+ {
|
|
|
+ it_map->second->map_light_group_list.insert(make_pair(pLightGroup->m_nID,pLightGroup));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
nRow++;
|
|
|
}
|
|
|
|
|
@@ -3746,7 +3771,8 @@ void CYAServerDlg::deal_areas()
|
|
|
count_total++;
|
|
|
count_person++;
|
|
|
// 超时
|
|
|
- is_true = difftime(current_time, it_card_person->second->enter_area_time) > over_time;
|
|
|
+ //is_true = difftime(current_time, it_card_person->second->enter_area_time) > over_time;
|
|
|
+ is_true = difftime(current_time, CFunctions::systime_to_timet(it_card_person->second->enter_area_time)) > over_time;
|
|
|
if(is_true){
|
|
|
if(!it_card_person->second->is_area_over_time){
|
|
|
it_card_person->second->is_area_over_time = true;
|
|
@@ -3776,7 +3802,8 @@ void CYAServerDlg::deal_areas()
|
|
|
|
|
|
count_vehicle++;
|
|
|
// 超时
|
|
|
- if(difftime(current_time, it_card_vehicle->second->enter_area_time) > over_time){
|
|
|
+ //if(difftime(current_time, it_card_vehicle->second->enter_area_time) > over_time){
|
|
|
+ if(difftime(current_time, CFunctions::systime_to_timet(it_card_vehicle->second->enter_area_time)) > over_time){
|
|
|
is_true = true;
|
|
|
if(!it_card_vehicle->second->is_area_over_time){
|
|
|
it_card_vehicle->second->is_area_over_time = true;
|
|
@@ -4091,7 +4118,8 @@ void CYAServerDlg::card_enter_area(std::shared_ptr<Card> card /* Card* card*/)
|
|
|
card_leave_area(card, it_area_cur->second);
|
|
|
}
|
|
|
card->area_id = it_area->second->area_id;
|
|
|
- card->enter_area_time = CFunctions::systime_to_timet(card->deal_time);
|
|
|
+ //card->enter_area_time = CFunctions::systime_to_timet(card->deal_time);
|
|
|
+ card->enter_area_time = card->deal_time;
|
|
|
card->pos_state = (0 == it_area->second->area_type_id) ? PDT_UP :PDT_DOWN;
|
|
|
|
|
|
if(CT_PERSON == card->card_type){
|
|
@@ -4126,7 +4154,8 @@ void CYAServerDlg::card_enter_area(std::shared_ptr<Card> card /* Card* card*/)
|
|
|
card_leave_area(card, it_area_cur->second);
|
|
|
}
|
|
|
card->area_id = it_area_reader->second->area_id;
|
|
|
- card->enter_area_time = CFunctions::systime_to_timet(card->deal_time);
|
|
|
+ //card->enter_area_time = CFunctions::systime_to_timet(card->deal_time);
|
|
|
+ card->enter_area_time = card->deal_time;
|
|
|
card->pos_state = (0 == it_area_reader->second->area_type_id) ? PDT_UP :PDT_DOWN;
|
|
|
if(CT_PERSON == card->card_type){
|
|
|
it_area_reader->second->area_card_list_person->insert(make_pair(card->card_id, card));
|
|
@@ -4423,9 +4452,10 @@ void CYAServerDlg::store_data_card(std::shared_ptr<Card> card /*Card* card*/, in
|
|
|
localtime_s(&local_time, &t);
|
|
|
strftime(_time, 30, "%Y-%m-%d %H:%M:%S", &local_time);
|
|
|
break;
|
|
|
- case HIS_LOCATION:
|
|
|
+
|
|
|
case HIS_AREA_LOCATION_ENTER:
|
|
|
case HIS_AREA_LOCATION_LEAVE:
|
|
|
+ case HIS_LOCATION:
|
|
|
sprintf_s(_time,
|
|
|
STR_LEN_TIME,
|
|
|
"%u-%u-%u %u:%u:%u.%u",
|
|
@@ -4471,8 +4501,13 @@ void CYAServerDlg::store_data_card(std::shared_ptr<Card> card /*Card* card*/, in
|
|
|
{
|
|
|
if(card->map_id != 0 && card->area_id != 0){
|
|
|
b_exec = true;
|
|
|
- localtime_s(&local_time_ex, &card->enter_area_time);
|
|
|
- strftime(_time_ex, 30, "%Y-%m-%d %H:%M:%S", &local_time_ex);
|
|
|
+ //localtime_s(&local_time_ex, &card->enter_area_time);
|
|
|
+ //strftime(_time_ex, 30, "%Y-%m-%d %H:%M:%S", &local_time_ex);
|
|
|
+ sprintf_s(_time_ex,
|
|
|
+ STR_LEN_TIME,
|
|
|
+ "%u-%u-%u %u:%u:%u.%u",
|
|
|
+ card->enter_area_time.wYear,card->enter_area_time.wMonth,card->enter_area_time.wDay,
|
|
|
+ card->enter_area_time.wHour,card->enter_area_time.wMinute,card->enter_area_time.wSecond,card->enter_area_time.wMilliseconds);
|
|
|
|
|
|
sprintf_s(sql, LENGTH_SQL,
|
|
|
"call add_area(%s, %d, %d, '%s','%s');",
|
|
@@ -4524,10 +4559,10 @@ void CYAServerDlg::store_data_card(std::shared_ptr<Card> card /*Card* card*/, in
|
|
|
try
|
|
|
{
|
|
|
if(b_exec){
|
|
|
- //CString sql_log = _T("");
|
|
|
- //sql_log = sql;
|
|
|
- //writeErrorLog(_T("SQL_S"),sql_log,true);
|
|
|
execute_sql(sql);
|
|
|
+ CString sql_log = _T("");
|
|
|
+ sql_log = sql;
|
|
|
+ writeErrorLog(_T("SQL_S"),sql_log,true);
|
|
|
}
|
|
|
}
|
|
|
catch (...)
|
|
@@ -4899,6 +4934,11 @@ void CYAServerDlg::deal_alarm_area(std::shared_ptr<Area> area, std::shared_ptr<A
|
|
|
*/
|
|
|
int CYAServerDlg::deal_traffic_lights(std::shared_ptr<Card> card)
|
|
|
{
|
|
|
+ if (card->x < 1E-3 && card->y < 1E-3)
|
|
|
+ {
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+
|
|
|
int nMapId = 0;
|
|
|
|
|
|
nMapId = card->map_id;
|
|
@@ -4982,14 +5022,24 @@ int CYAServerDlg::deal_traffic_lights(std::shared_ptr<Card> card)
|
|
|
{
|
|
|
it_ll->second->m_nColor = COLOR_GREEN;
|
|
|
if(LIGHT_CTRL_STATE::CTRL_STATE_AUTO == it_ll->second->m_nIsCtrl){
|
|
|
+ TRACE(_T("all show green \r\n"));
|
|
|
send_call_light(CC_SET_LIGHTS_STATE,it_ll->second->m_nID, it_ll->second->m_nIsCtrl, it_ll->second->m_nColor,GREEN_UP);
|
|
|
}
|
|
|
}
|
|
|
card->b_enter_intersection = false;
|
|
|
- //释放红绿灯组的控制权
|
|
|
- card->m_nLightGroupId = -1;
|
|
|
|
|
|
//发送控制消息给红绿灯组,
|
|
|
+ LightGroupMap::iterator it_group = it_map->second->map_light_group_list.find(card->m_nLightGroupId);
|
|
|
+ if (it_group != it_map->second->map_light_group_list.end())
|
|
|
+ {
|
|
|
+ if (it_group->second->isAllLightColor(COLOR_GREEN))
|
|
|
+ {
|
|
|
+ //释放红绿灯组的控制权
|
|
|
+ card->m_nLightGroupId = -1;
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//控制成功,退出;控制失败,报警并退出
|
|
|
//需要代码实现
|
|
|
}
|
|
@@ -5047,6 +5097,7 @@ int CYAServerDlg::deal_traffic_lights(std::shared_ptr<Card> card)
|
|
|
if (it_group->second->isExist(it_light->second))
|
|
|
{
|
|
|
bFind = true;
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -5133,7 +5184,18 @@ int CYAServerDlg::deal_traffic_lights(std::shared_ptr<Card> card)
|
|
|
}
|
|
|
|
|
|
if(LIGHT_CTRL_STATE::CTRL_STATE_AUTO == it_glight->second->m_nIsCtrl){
|
|
|
- send_call_light(CC_SET_LIGHTS_STATE,it_glight->second->m_nID, it_glight->second->m_nIsCtrl, it_glight->second->m_nColor,GREEN_UP);
|
|
|
+ switch (it_glight->second->m_nColor)
|
|
|
+ {
|
|
|
+ case COLOR_GREEN:
|
|
|
+ TRACE(_T("group : show green \r\n"));
|
|
|
+ send_call_light(CC_SET_LIGHTS_STATE,it_glight->second->m_nID, it_glight->second->m_nIsCtrl, it_glight->second->m_nColor,GREEN_UP);
|
|
|
+ break;
|
|
|
+ case COLOR_RED:
|
|
|
+ TRACE(_T("group : show red \r\n"));
|
|
|
+ send_call_light(CC_SET_LIGHTS_STATE,it_glight->second->m_nID, it_glight->second->m_nIsCtrl, it_glight->second->m_nColor,RED_CROSS);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ //send_call_light(CC_SET_LIGHTS_STATE,it_glight->second->m_nID, it_glight->second->m_nIsCtrl, it_glight->second->m_nColor,GREEN_UP);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -6809,7 +6871,8 @@ void CYAServerDlg::load_his_area()
|
|
|
it->second->area_id = atoi(pRow[1]);
|
|
|
it->second->map_id = atoi(pRow[2]);
|
|
|
enter_time = pRow[3];
|
|
|
- API_StringToTime(enter_time, it->second->enter_area_time);
|
|
|
+ //API_StringToTime(enter_time, it->second->enter_area_time);
|
|
|
+ CFunctions::string2systemtime(enter_time,it->second->enter_area_time);
|
|
|
nRow++;
|
|
|
}
|
|
|
}
|
|
@@ -6860,7 +6923,8 @@ void CYAServerDlg::load_his_card_postion()
|
|
|
it->second->area_id = atoi(pRow[5]);
|
|
|
it->second->map_id = atoi(pRow[6]);
|
|
|
enter_time = pRow[7];
|
|
|
- API_StringToTime(enter_time, it->second->enter_area_time);
|
|
|
+ //API_StringToTime(enter_time, it->second->enter_area_time);
|
|
|
+ CFunctions::string2systemtime(enter_time,it->second->enter_area_time);
|
|
|
start_time = pRow[8];
|
|
|
API_StringToTime(start_time, it->second->down_time);
|
|
|
it->second->pos_state = PDT_DOWN;
|
|
@@ -9525,7 +9589,6 @@ std::string CYAServerDlg::get_json_new_device_state()
|
|
|
state_dev.append(it_ctrl_reader->second->reader_id);
|
|
|
state_dev.append(it_ctrl_reader->second->device_type_id);
|
|
|
state_dev.append(it_ctrl_reader->second->reader_state);
|
|
|
- //state_dev.append(it_ctrl_reader->second->get_state_text());
|
|
|
int ms = 1000; //转为ms
|
|
|
//入井时间戳
|
|
|
double t = *((int64_t*)&it_ctrl_reader->second->rec_time)*ms;
|