Files
TSCP/TSCP/src/APP/ciapp/Switch/SwitchDataManage.c
T

3951 lines
98 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/********************************************************
*
* 文 件 名: SwitchDataManage.c
* 版权说明: 北京交控科技有限公司
* 创建时间: 2012-03-19
* 作 者: 联锁组
* 功能描述: 道岔数据管理
* 修改记录:
*
********************************************************/
#include "SwitchDataManage.h"
#include "../LogicProcess/InterlockLogicProcess.h"
SwitchDataStruct SwitchDataStru[SWITCH_SUM_MAX]; /*定义道岔数据结构体*/
SwitchDataStructCC SwitchDataStruCC[SWITCH_SUM_MAX]; /*定义道岔数据结构体-车车*/
/*
* 功能描述: 获取指定ID道岔数据
* 参数说明:
* 返回值
SwitchDataStruct *
*/
SwitchDataStruct *GetSwitchData(void)
{
return SwitchDataStru;
}
/*
* 功能描述: 获取指定ID道岔数据车车
* 参数说明:
* 返回值
SwitchDataStructCC *
*/
SwitchDataStructCC* GetSwitchDataCC(void)
{
return SwitchDataStruCC;
}
/*
* 功能描述: 获取指定ID道岔引导总锁状态
* 参数说明: const UINT16 switchId, 道岔ID
* 返回值 0: 获取数据失败
* >0: 引导总锁状态
*/
UINT8 GetSwitchYLockState(const UINT16 switchId)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT8 retVal = CI_ERROR;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (bufIndex < SWITCH_SUM_MAX)
{
retVal = SwitchDataStru[bufIndex].YLockState;
}
else
{
retVal = CI_ERROR;
}
return retVal;
}
/*
* 功能描述: 设置指定ID道岔引导总锁状态
* 参数说明: const UINT16 switchId, 道岔ID
* const UINT8 yLockState, 引导总锁状态
* 返回值
*
*/
void SetSwitchYLockState(const UINT16 switchId, const UINT8 yLockState)
{
UINT16 bufIndex = 0u; /*数组下标*/
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (bufIndex < SWITCH_SUM_MAX)
{
if ((SWITCH_LOCK_YINZONG_NO == yLockState) || (SWITCH_LOCK_YINZONG_YES == yLockState))
{
SwitchDataStru[bufIndex].YLockState = yLockState; /*道岔引导总锁状态*/
}
else
{
/*不做处理*/
}
}
else
{
/*不做处理*/
}
}
/*
* 功能描述: 获取指定ID道岔锁闭状态
* 参数说明: const UINT16 switchId, 道岔ID
* 返回值 0: 获取数据失败
* >0: 锁闭状态
*/
UINT8 GetSwitchLockStatus(const UINT16 switchId)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT8 retVal = CI_ERROR;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (bufIndex < SWITCH_SUM_MAX)
{
retVal = SwitchDataStru[bufIndex].LockStatus;
}
else
{
retVal = CI_ERROR;
}
return retVal;
}
/*
* 功能描述: 设置指定ID道岔锁闭状态
* 参数说明:
* const UINT8 lockType,锁闭类型
* const UINT16 pLockId,锁闭id
* const UINT16 switchId, 道岔ID
* const UINT8 lockCommand, 锁闭命令
* 返回值 void
*/
void SetSwitchLockStatus(const UINT8 pLockType,const UINT16 pLockId,const UINT16 switchId, const UINT8 lockCommand)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT8 retVal = CI_ERROR;
UINT8 switchLockStatus = 0u;
UINT16 ii =0u;/*游标*/
UINT16 jj = 0u;/*游标*/
UINT16 kk = 0u;/*游标*/
UINT8 findFlag = 0u;/*查找标志*/
INT16 emptyIndex = -1;/*空位索引位置*/
INT16 targetIndex = -1;/*目标索引*/
UINT8 cLocalCiId = 0U;
UINT8 cSwitchBelongCiId = 0U;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
switchLockStatus = GetSwitchLockStatus(switchId); /*获取道岔锁闭状态*/
cLocalCiId = GetSystemParaLocalCiId();
if (bufIndex < SWITCH_SUM_MAX)
{
switch (pLockType)
{
case SWITCH_PLOCKTYPE_DANSUO:/*锁闭类型为单锁*/
{
if (SWITCH_LOCK_DANSUO_SET == lockCommand )
{/*设置单锁*/
if ((SWITCH_LOCK_STATUS_PROTECT == switchLockStatus) || (SWITCH_LOCK_STATUS_DAP == switchLockStatus))
{
SwitchDataStru[bufIndex].LockStatus = SWITCH_LOCK_STATUS_DAP; /*设置道岔单锁且防护锁闭状态*/
}
else
{
SwitchDataStru[bufIndex].LockStatus = SWITCH_LOCK_STATUS_DANSUO; /*设置道岔单锁状态*/
}
}
else if (SWITCH_LOCK_DANSUO_CANCEL == lockCommand)
{/*取消单锁*/
if (SWITCH_LOCK_STATUS_PROTECT == switchLockStatus)
{
SwitchDataStru[bufIndex].LockStatus = SWITCH_LOCK_STATUS_PROTECT; /*保持道岔防护锁闭状态*/
}
else if (SWITCH_LOCK_STATUS_DAP == switchLockStatus)
{
SwitchDataStru[bufIndex].LockStatus = SWITCH_LOCK_STATUS_PROTECT; /*设置道岔防护锁闭状态*/
}
else
{
SwitchDataStru[bufIndex].LockStatus = SWITCH_LOCK_STATUS_NO; /*设置道岔未锁闭状态*/
}
}
else
{
/*非法值不处理*/
}
retVal = CI_SUCCESS;
break;
}
case SWITCH_PLOCKTYPE_ROUTE:/*锁闭类型为被进路防护锁闭*/
{
if (SWITCH_LOCK_PROTECT_SET == lockCommand)
{/*设置防护锁闭*/
findFlag = 0u;/*置未找到*/
emptyIndex = -1;/*空位索引*/
/*查找被防护锁闭进路id是否存在,存在,退出;不存在,找一个存放位置,更新被锁闭的进路数量*/
for (ii=0U;ii<SWITCH_MAX_PROTECT_LOCKED_NUM;ii++)
{
if (emptyIndex < 0)/*空位索引小于0,才查找空位索引*/
{
if (0U == SwitchDataStru[bufIndex].PLockedRouteIdArr[ii])
{
emptyIndex = (INT16)ii;/*空位值为0,表示为空位,记住索引*/
}
}
if (pLockId == SwitchDataStru[bufIndex].PLockedRouteIdArr[ii])
{/*找到被锁闭的id*/
findFlag = 1u;
}
}
if (0u == findFlag)
{/*没找到被锁闭id*/
if (emptyIndex >= 0)
{/*且空位存在*/
SwitchDataStru[bufIndex].PLockedRouteIdArr[emptyIndex] = pLockId;/*设置被锁闭id*/
SwitchDataStru[bufIndex].PLockedRouteNum++; /*被锁闭id数量增加1个*/
}
else
{/*超过软件支持的最大防护锁闭设备数目,输出打印信息*/
debug_infor_printf((const)"Set switch id %d PLOCK by routeId %d fail,no empty space\n",bufIndex,pLockId);
}
}
}
else if (SWITCH_LOCK_PROTECT_CANCEL == lockCommand)
{/*取消防护锁闭*/
targetIndex = -1;/*目标索引*/
/*如果没找到,返回*/
/*找到,设为0,且把数量-1*/
for (ii=0;ii<SWITCH_MAX_PROTECT_LOCKED_NUM;ii++)
{
if (SwitchDataStru[bufIndex].PLockedRouteIdArr[ii] == pLockId)
{
targetIndex = (INT16)ii;
SwitchDataStru[bufIndex].PLockedRouteIdArr[ii] = 0U;/*设为0*/
break;
}
}
if (targetIndex >=0)/*找到了*/
{
if (SwitchDataStru[bufIndex].PLockedRouteNum > 0U)
{
SwitchDataStru[bufIndex].PLockedRouteNum--;/*减1处理*/
}
}
}
else
{
/*非法命令,不处理*/
}
retVal = CI_SUCCESS;
break;
}
case SWITCH_PLOCKTYPE_OVERLAP:/*锁闭类型为被保护区段防护锁闭*/
{
if (SWITCH_LOCK_PROTECT_SET == lockCommand)
{/*设置防护锁闭*/
findFlag = 0u;/*置未找到*/
emptyIndex = -1;/*空位索引*/
/*查找被防护锁闭保护区段id是否存在,存在,退出;不存在,找一个存放位置,更新被锁闭的保护区段数量*/
for (ii=0;ii<SWITCH_MAX_PROTECT_LOCKED_NUM;ii++)
{
if (emptyIndex < 0)/*空位索引小于0,才查找空位索引*/
{
if (0u == SwitchDataStru[bufIndex].PLockedOverlapIdArr[ii])
{
emptyIndex = (INT16)ii;/*空位值为0,表示为空位,记住索引*/
}
}
if (pLockId == SwitchDataStru[bufIndex].PLockedOverlapIdArr[ii])
{/*找到被锁闭的id*/
findFlag = 1u;
}
}
if (0u == findFlag)
{/*没找到被锁闭id*/
if (emptyIndex >= 0)
{/*且空位存在*/
SwitchDataStru[bufIndex].PLockedOverlapIdArr[emptyIndex] = pLockId;/*设置被锁闭id*/
SwitchDataStru[bufIndex].PLockedOverlapNum++; /*被锁闭id数量增加1个*/
}
else
{
debug_infor_printf((const)"Set switch id %d PLOCK by overlapId %d fail,no empty space\n",bufIndex,pLockId);
}
}
}
else if (SWITCH_LOCK_PROTECT_CANCEL == lockCommand)
{/*取消防护锁闭*/
targetIndex = -1;/*目标索引*/
/*如果没找到,返回*/
/*找到,设为0,且把数量-1*/
for (ii=0u;ii<SWITCH_MAX_PROTECT_LOCKED_NUM;ii++)
{
if (SwitchDataStru[bufIndex].PLockedOverlapIdArr[ii] == pLockId)
{
targetIndex = (INT16)ii;
SwitchDataStru[bufIndex].PLockedOverlapIdArr[ii] = 0U;/*设为0*/
break;
}
}
if (targetIndex >=0)/*找到了*/
{
if (SwitchDataStru[bufIndex].PLockedOverlapNum > 0U)
{
SwitchDataStru[bufIndex].PLockedOverlapNum--;/*减1处理*/
}
}
}
else
{
/*非法命令,不处理*/
}
retVal = CI_SUCCESS;
break;
}
case SWITCH_PLOCKTYPE_NONROUTE:/*锁闭类型为被非进路防护锁闭*/
{
if (SWITCH_LOCK_PROTECT_SET == lockCommand)
{/*设置防护锁闭*/
findFlag = 0u;/*置未找到*/
emptyIndex = -1;/*空位索引*/
/*查找被防护非进路id是否存在,存在,退出;不存在,找一个存放位置,更新被锁闭的非进路数量*/
for (ii=0u;ii<SWITCH_MAX_PROTECT_LOCKED_NUM;ii++)
{
if (emptyIndex < 0)/*空位索引小于0,才查找空位索引*/
{
if (0u == SwitchDataStru[bufIndex].PLockedNonRouteIdArr[ii])
{
emptyIndex = (INT16)ii;/*空位值为0,表示为空位,记住索引*/
}
}
if (pLockId == SwitchDataStru[bufIndex].PLockedNonRouteIdArr[ii])
{/*找到被锁闭的id*/
findFlag = 1u;
}
}
if (0u == findFlag)
{/*没找到被锁闭id*/
if (emptyIndex >= 0)
{/*且空位存在*/
SwitchDataStru[bufIndex].PLockedNonRouteIdArr[emptyIndex] = pLockId;/*设置被锁闭id*/
SwitchDataStru[bufIndex].PLockedNonRouteNum++; /*被锁闭id数量增加1个*/
}
else
{/*超过软件支持的最大防护锁闭设备数目,输出打印信息*/
debug_infor_printf((const)"Set switch id %d PLOCK by nonRouteId %d fail,no empty space\n",bufIndex,pLockId);
}
}
}
else if (SWITCH_LOCK_PROTECT_CANCEL == lockCommand)
{/*取消防护锁闭*/
targetIndex = -1;/*目标索引*/
/*如果没找到,返回*/
/*找到,设为0,且把数量-1*/
for (ii=0u;ii<SWITCH_MAX_PROTECT_LOCKED_NUM;ii++)
{
if (SwitchDataStru[bufIndex].PLockedNonRouteIdArr[ii] == pLockId)
{
targetIndex = (INT16)ii;
SwitchDataStru[bufIndex].PLockedNonRouteIdArr[ii] = 0;/*设为0*/
break;
}
}
if (targetIndex >=0)/*找到了*/
{
if (SwitchDataStru[bufIndex].PLockedNonRouteNum > 0U)
{
SwitchDataStru[bufIndex].PLockedNonRouteNum--;/*减1处理*/
}
}
}
else
{
/*非法命令,不处理*/
}
retVal = CI_SUCCESS;
break;
}
case SWITCH_PLOCKTYPE_LOGROUTE:/*锁闭类型为被逻辑进路防护锁闭*/
{
SetSwitchLockStaUseByLogRoute(pLockId, switchId, lockCommand);
retVal = CI_SUCCESS;
break;
}
case SWITCH_PLOCKTYPE_NOROUTE_NOOVERLAP_NONONROUTE:/*解除道岔防护锁闭*/
{/*解除道岔防护锁闭,解除被进路/保护区段/非进路锁闭,清所有ID*/
SwitchDataStru[bufIndex].PLockedRouteNum = 0u;
SwitchDataStru[bufIndex].PLockedOverlapNum = 0u;
SwitchDataStru[bufIndex].PLockedNonRouteNum = 0u;
SwitchDataStruCC[bufIndex].PLockedLogRouteNum = 0u;
for (ii=0u;ii<SWITCH_MAX_PROTECT_LOCKED_NUM;ii++)
{
SwitchDataStru[bufIndex].PLockedNonRouteIdArr[ii] = 0u;
SwitchDataStru[bufIndex].PLockedOverlapIdArr[ii] = 0u;
SwitchDataStru[bufIndex].PLockedRouteIdArr[ii] = 0u;
SwitchDataStruCC[bufIndex].PLockedLogRouteIdArr[ii] = 0u;
}
retVal = CI_SUCCESS;
}
break;
case SWITCH_PLOCKTYPE_AXISSEC:/*锁闭类型为被计轴区段防护锁闭*/
{
if (SWITCH_LOCK_PROTECT_SET == lockCommand)
{/*设置防护锁闭*/
findFlag = 0u;/*置未找到*/
emptyIndex = -1;/*空位索引*/
/*查找被防护计轴区段id是否存在,存在,退出;不存在,找一个存放位置,更新被锁闭的计轴区段数量*/
for (ii = 0u; ii < SWITCH_MAX_PROTECT_LOCKED_NUM; ii++)
{
if (emptyIndex < 0)/*空位索引小于0,才查找空位索引*/
{
if (0u == SwitchDataStru[bufIndex].PLockedAxisSecIdArr[ii])
{
emptyIndex = (INT16)ii;/*空位值为0,表示为空位,记住索引*/
}
}
if (pLockId == SwitchDataStru[bufIndex].PLockedAxisSecIdArr[ii])
{/*找到被锁闭的id*/
findFlag = 1u;
}
}
if (0u == findFlag)
{/*没找到被锁闭id*/
if (emptyIndex >= 0)
{/*且空位存在*/
SwitchDataStru[bufIndex].PLockedAxisSecIdArr[emptyIndex] = pLockId;/*设置被锁闭id*/
SwitchDataStru[bufIndex].PLockedAxisSecNum++; /*被锁闭id数量增加1个*/
}
else
{/*超过软件支持的最大防护锁闭设备数目,输出打印信息*/
debug_infor_printf((const)"Set switch id %d PLOCK by axis %d fail,no empty space\n", bufIndex, pLockId);
}
}
}
else if (SWITCH_LOCK_PROTECT_CANCEL == lockCommand)
{/*取消防护锁闭*/
targetIndex = -1;/*目标索引*/
/*如果没找到,返回*/
/*找到,设为0,且把数量-1*/
for (ii = 0u; ii < SWITCH_MAX_PROTECT_LOCKED_NUM; ii++)
{
if (SwitchDataStru[bufIndex].PLockedAxisSecIdArr[ii] == pLockId)
{
targetIndex = (INT16)ii;
SwitchDataStru[bufIndex].PLockedAxisSecIdArr[ii] = 0;/*设为0*/
break;
}
}
if (targetIndex >= 0)/*找到了*/
{
if (SwitchDataStru[bufIndex].PLockedAxisSecNum > 0U)
{
SwitchDataStru[bufIndex].PLockedAxisSecNum--;/*减1处理*/
}
}
}
else
{
/*非法命令,不处理*/
}
retVal = CI_SUCCESS;
break;
}
default:
{
/*类型非法,置返回标志错误*/
retVal = CI_ERROR;
break;
}
}
if (CI_SUCCESS == retVal)
{
cSwitchBelongCiId = GetSwitchBelongCiId(switchId);
/*计算道岔真正的锁闭状态,分包含单锁和不包含单锁两种*/
if ((SWITCH_LOCK_STATUS_DANSUO == SwitchDataStru[bufIndex].LockStatus) ||
(SWITCH_LOCK_STATUS_DAP == SwitchDataStru[bufIndex].LockStatus))/*道岔状态包含单锁*/
{
if (SwitchDataStru[bufIndex].PLockedNonRouteNum + SwitchDataStru[bufIndex].PLockedOverlapNum +
SwitchDataStru[bufIndex].PLockedRouteNum + SwitchDataStruCC[bufIndex].PLockedLogRouteNum + SwitchDataStru[bufIndex].PLockedAxisSecNum > 0u)
{/*被防护锁闭的设备数目大于0*/
SwitchDataStru[bufIndex].LockStatus = SWITCH_LOCK_STATUS_DAP;
}
else
{
if (cLocalCiId != cSwitchBelongCiId)
{
/*非本控区道岔,在进路/保护区段解锁时,不更新防护锁闭状态*/
}
else
{
SwitchDataStru[bufIndex].LockStatus = SWITCH_LOCK_STATUS_DANSUO;
}
}
}
else
{/*不包含单锁*/
if (SwitchDataStru[bufIndex].PLockedNonRouteNum + SwitchDataStru[bufIndex].PLockedOverlapNum +
SwitchDataStru[bufIndex].PLockedRouteNum + SwitchDataStruCC[bufIndex].PLockedLogRouteNum + SwitchDataStru[bufIndex].PLockedAxisSecNum > 0u)
{/*被防护锁闭的设备数目大于0*/
SwitchDataStru[bufIndex].LockStatus = SWITCH_LOCK_STATUS_PROTECT;
}
else
{
if (cLocalCiId != cSwitchBelongCiId)
{
/*非本控区道岔,在进路/保护区段解锁时,不更新防护锁闭状态*/
}
else
{
SwitchDataStru[bufIndex].LockStatus = SWITCH_LOCK_STATUS_NO;
}
}
}
retVal = CI_SUCCESS;
}
}
else
{
retVal = CI_ERROR;
}
if (CI_ERROR == retVal)
{
debug_infor_printf((const)"SetSwitchLockStatus ERROR LockType: %d , switchID%d, command : %d\n", pLockType, switchId, lockCommand);
}
}
/*
* 功能描述: 办理逻辑进路时设置指定ID道岔锁闭状态
* 参数说明: const UINT8 lockType,锁闭类型
* const UINT16 pLockLogRouteId,锁闭的逻辑进路id
* const UINT16 switchId, 道岔ID
* const UINT8 lockCommand, 锁闭命令
* 返回值 0: 设置失败
* 1: 设置成功
* 备注: 可设置被进路防护锁闭、解出防护锁闭)
*/
void SetSwitchLockStaUseByLogRoute(const UINT16 pLockLogRouteId, const UINT16 switchId, const UINT8 lockCommand)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT8 switchLockStatus = 0u;
UINT16 ii = 0u;/*游标*/
UINT16 jj = 0u;/*游标*/
UINT16 kk = 0u;/*游标*/
UINT8 findFlag = 0u;/*查找标志*/
INT16 emptyIndex = -1;/*空位索引位置*/
INT16 targetIndex = -1;/*目标索引*/
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
switchLockStatus = GetSwitchLockStatus(switchId); /*获取道岔锁闭状态*/
if (bufIndex < SWITCH_SUM_MAX)
{
if (SWITCH_LOCK_PROTECT_SET == lockCommand)
{/*设置防护锁闭*/
findFlag = 0u;/*置未找到*/
emptyIndex = -1;/*空位索引*/
/*查找被防护锁闭进路id是否存在,存在,退出;不存在,找一个存放位置,更新被锁闭的进路数量*/
for (ii = 0; ii < SWITCH_MAX_PROTECT_LOCKED_NUM; ii++)
{
if (emptyIndex < 0)/*空位索引小于0,才查找空位索引*/
{
if (0U == SwitchDataStruCC[bufIndex].PLockedLogRouteIdArr[ii])
{
emptyIndex = (INT16)ii;/*空位值为0,表示为空位,记住索引*/
}
}
if (pLockLogRouteId == SwitchDataStruCC[bufIndex].PLockedLogRouteIdArr[ii])
{/*找到被锁闭的id*/
findFlag = 1u;
}
}
if (0u == findFlag)
{/*没找到被锁闭id*/
if (emptyIndex >= 0)
{/*且空位存在*/
SwitchDataStruCC[bufIndex].PLockedLogRouteIdArr[emptyIndex] = pLockLogRouteId;/*设置被锁闭id*/
SwitchDataStruCC[bufIndex].PLockedLogRouteNum++; /*被锁闭id数量增加1个*/
}
else
{/*超过软件支持的最大防护锁闭设备数目,输出打印信息*/
debug_infor_printf((const)"Set switch id %d PLOCK by routeId %d fail,no empty space\n", bufIndex, pLockLogRouteId);
}
}
}
else if (SWITCH_LOCK_PROTECT_CANCEL == lockCommand)
{/*取消防护锁闭*/
targetIndex = -1;/*目标索引*/
/*如果没找到,返回*/
/*找到,设为0,且把数量-1*/
for (ii = 0; ii < SWITCH_MAX_PROTECT_LOCKED_NUM; ii++)
{
if (SwitchDataStruCC[bufIndex].PLockedLogRouteIdArr[ii] == pLockLogRouteId)
{
targetIndex = (INT16)ii;
SwitchDataStruCC[bufIndex].PLockedLogRouteIdArr[ii] = 0;/*设为0*/
break;
}
}
if (targetIndex >= 0)/*找到了*/
{
if (SwitchDataStruCC[bufIndex].PLockedLogRouteNum > 0U)
{
SwitchDataStruCC[bufIndex].PLockedLogRouteNum--;/*减1处理*/
}
}
}
else
{
/*非法命令,不处理*/
}
}
}
/*
* 功能描述: 设置其它控区指定ID道岔的锁闭状态
* 参数说明: const UINT16 switchId, 道岔ID
* const UINT8 lockStatus, 锁闭状态
* 返回值
* Modified By LQ 2024.12.09(适配防护道岔跨控区)
*/
void SetOtherCiSwitchLockStatus(const UINT16 switchId, const UINT8 lockStatus)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT8 ii = 0U;
UINT8 cLocalCiId = 0U;
UINT8 cRouteBelongCiId = 0U; /*进路所属控区*/
UINT8 cOverlapBelongCiId = 0U; /*保护区段所属控区*/
UINT8 cRouteFindFlag = CI_ERROR;
UINT8 cOverlapFindFlag = CI_ERROR;
cLocalCiId = GetSystemParaLocalCiId();
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (bufIndex < SWITCH_SUM_MAX)
{
/****** 1.判断该防护道岔是否被本控区进路/保护区段防护锁闭 ******/
for (ii = 0U; ii < SWITCH_MAX_PROTECT_LOCKED_NUM; ii++)
{
cRouteBelongCiId = GetRouteBelongCiId(SwitchDataStru[bufIndex].PLockedRouteIdArr[ii]);
if ((0U != cRouteBelongCiId) && (cLocalCiId == cRouteBelongCiId))
{
cRouteFindFlag = CI_SUCCESS;
break; /*存在本控区进路防护锁闭,停止变遍历*/
}
else
{
/*继续遍历*/
}
}
for (ii = 0U; ii < SWITCH_MAX_PROTECT_LOCKED_NUM; ii++)
{
cOverlapBelongCiId = GetOverlapBelongCiId(SwitchDataStru[bufIndex].PLockedOverlapIdArr[ii]);
if ((0U != cOverlapBelongCiId) && (cLocalCiId == cOverlapBelongCiId))
{
cOverlapFindFlag = CI_SUCCESS;
break; /*存在本控区保护区段防护锁闭,停止变遍历*/
}
else
{
/*继续遍历*/
}
}
/****** 2.更新防护道岔的锁闭状态 ******/
switch (lockStatus)
{
case SWITCH_LOCK_STATUS_NO:
{
if ((CI_SUCCESS == cRouteFindFlag) || (CI_SUCCESS == cOverlapFindFlag))
{
if (SWITCH_LOCK_STATUS_DAP == SwitchDataStru[bufIndex].LockStatus)
{
/*场景:本控区对防护道岔设置防护锁闭后,防护道岔控区的防护道岔由单锁->未锁闭,本控区需要更新为防护锁闭*/
SwitchDataStru[bufIndex].LockStatus = SWITCH_LOCK_STATUS_PROTECT;
}
else
{
/*保持当前状态不更新*/
}
}
else
{
SwitchDataStru[bufIndex].LockStatus = lockStatus; /*更新道岔锁闭为为锁闭*/
}
break;
}
case SWITCH_LOCK_STATUS_DANSUO:
{
if ((CI_SUCCESS == cRouteFindFlag) || (CI_SUCCESS == cOverlapFindFlag))
{
if (SWITCH_LOCK_STATUS_PROTECT == SwitchDataStru[bufIndex].LockStatus)
{
/*场景:本控区对防护道岔设置防护锁闭后,防护道岔控区的防护道岔由未锁闭->单锁,本控区需要更新为单锁+防护锁闭*/
SwitchDataStru[bufIndex].LockStatus = SWITCH_LOCK_STATUS_DAP;
}
else
{
/*保持当前状态不更新*/
}
}
else
{
SwitchDataStru[bufIndex].LockStatus = lockStatus; /*更新道岔锁闭为为锁闭*/
}
break;
}
case SWITCH_LOCK_STATUS_PROTECT:
{
SwitchDataStru[bufIndex].LockStatus = lockStatus; /*更新道岔锁闭为防护锁闭*/
break;
}
case SWITCH_LOCK_STATUS_DAP:
{
SwitchDataStru[bufIndex].LockStatus = lockStatus; /*更新道岔锁闭为单锁+防护锁闭*/
break;
}
default:
break;
}
}
else
{
/*保护区段ID非法,不做处理*/
}
}
/*
* 功能描述: 获取指定ID道岔封锁状态
* 参数说明: const UINT16 switchId, 道岔ID
* 返回值 0: 获取数据失败
* >0: 封锁状态
*/
UINT8 GetSwitchFLockState(const UINT16 switchId)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT8 retVal = CI_ERROR;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (bufIndex < SWITCH_SUM_MAX)
{
retVal = SwitchDataStru[bufIndex].FLockState;
}
else
{
retVal = CI_ERROR;
}
return retVal;
}
/*
* 功能描述: 设置指定ID道岔封锁状态
* 参数说明: const UINT16 switchId, 道岔ID
* const UINT8 fLockState, 封锁状态
* 返回值
*
*/
void SetSwitchFLockState(const UINT16 switchId, const UINT8 fLockState)
{
UINT16 bufIndex = 0u; /*数组下标*/
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (bufIndex < SWITCH_SUM_MAX)
{
if ((SWITCH_LOCK_FENGSUO_NO == fLockState) || (SWITCH_LOCK_FENGSUO_YES == fLockState))
{
SwitchDataStru[bufIndex].FLockState = fLockState; /*道岔封锁状态*/
}
else
{
/*不做处理*/
}
}
else
{
/*不做处理*/
}
}
/*
* 功能描述: 获取指定ID道岔之前位置
* 参数说明: const UINT16 switchId, 道岔ID
* 返回值 0: 获取数据失败
* >0: 之前位置
*/
UINT8 GetSwitchPrePosition(const UINT16 switchId)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT8 retVal = CI_ERROR;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (bufIndex < SWITCH_SUM_MAX)
{
retVal = SwitchDataStru[bufIndex].SwitchPrePosition;
}
else
{
retVal = CI_ERROR;
}
return retVal;
}
/*
* 功能描述: 设置指定ID道岔之前位置
* 参数说明: const UINT16 switchId, 道岔ID
* const UINT8 prePosition, 之前位置
* 返回值 0: 设置失败
* 1: 设置成功
*/
UINT8 SetSwitchPrePosition(const UINT16 switchId, const UINT8 prePosition)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT8 retVal = CI_ERROR;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (bufIndex < SWITCH_SUM_MAX)
{
if ((SWITCH_POSITION_DINGWEI == prePosition) || (SWITCH_POSITION_FANWEI == prePosition) ||
(SWITCH_POSITION_SIKAI == prePosition) || (SWITCH_POSITION_JICHA == prePosition) ||
(SWITCH_POSITION_MOVE == prePosition))
{/* zt 删除单轨相关代码 2022-02-15 */
SwitchDataStru[bufIndex].SwitchPrePosition = prePosition; /*道岔之前位置*/
retVal = CI_SUCCESS;
}
else
{
retVal = CI_ERROR;
}
}
else
{
retVal = CI_ERROR;
}
return retVal;
}
/*
* 功能描述: 获取指定ID道岔当前位置
* 参数说明: const UINT16 switchId, 道岔ID
* 返回值 SWITCH_POSITION_INVALID: 位置无效
* 其它: 当前位置
*/
UINT8 GetSwitchCurPosition(const UINT16 switchId)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT8 retVal = SWITCH_POSITION_INVALID;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (bufIndex < SWITCH_SUM_MAX)
{
retVal = SwitchDataStru[bufIndex].SwitchCurPosition;
}
else
{
retVal = SWITCH_POSITION_INVALID;
}
return retVal;
}
/*
* 功能描述: 获取指定ID单独道岔当前位置
* 参数说明: const UINT16 switchId, 道岔ID
* 返回值 0: 获取数据失败
* >0: 当前位置
*/
UINT8 GetSingleSwitchCurPosition(const UINT16 switchId)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT8 retVal = CI_ERROR;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (SWITCH_SUM_MAX > bufIndex)
{
retVal = SwitchDataStru[bufIndex].SingleSwitchCurPosition;
}
else
{
retVal = CI_ERROR;
}
return retVal;
}
/*
* 功能描述: 设置指定ID道岔当前位置
* 参数说明: const UINT16 switchId, 道岔ID
* const UINT8 curPosition, 当前位置
* 返回值
*
*/
void SetSwitchCurPosition(const UINT16 switchId, const UINT8 curPosition)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT8 moveTimeState = 0u;
UINT8 ciPattern = GetLocalCiPattern();
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (bufIndex < SWITCH_SUM_MAX)
{
/*全电子联锁*/
if (CI_PATTERN_FULL_ELECTRONIC == ciPattern)
{/*全电子联锁双动道岔逻辑位置由两个单独共同组成,动作开始时间按单个道岔动作时间计算,因此不在此处计算*/
/*设置道岔之前位置*/
SwitchDataStru[bufIndex].SwitchPrePosition = GetSwitchCurPosition(switchId);
/*道岔当前位置*/
SwitchDataStru[bufIndex].SwitchCurPosition = curPosition;
}
else
{
if ((SWITCH_POSITION_DINGWEI == curPosition) || (SWITCH_POSITION_FANWEI == curPosition))
{/* zt 删除单轨相关代码 2022-02-15 */
/*设置道岔之前位置*/
SwitchDataStru[bufIndex].SwitchPrePosition = GetSwitchCurPosition(switchId);
/*道岔当前位置*/
SwitchDataStru[bufIndex].SwitchCurPosition = curPosition;
/*清除道岔开始动作时间*/
SetSwitchMoveStartCycNum(switchId, 0u);
}
else if ((SWITCH_POSITION_SIKAI == curPosition) || (SWITCH_POSITION_MOVE == curPosition))
{
moveTimeState = SystemOverTimeCheck(GetSwitchMoveStartCycNum(switchId), GetSystemParaSwitchMoveCyc());
if (CI_TIME_NO == moveTimeState)
{
/*未设置动作时间*/
/*设置道岔之前位置*/
SwitchDataStru[bufIndex].SwitchPrePosition = GetSwitchCurPosition(switchId);
/*道岔当前位置*/
SwitchDataStru[bufIndex].SwitchCurPosition = curPosition;
if (CI_TRUE == CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SWITCH, switchId))
{ /*只有具有本联锁控制权的道岔才设置道岔挤岔状态*/
/*设置道岔开始动作时间*/
SetSwitchMoveStartCycNum(switchId, Get2oo2CurCycleNum());
}
}
else if (CI_TIME_IN == moveTimeState)
{
/*计时中*/
/*设置道岔之前位置*/
SwitchDataStru[bufIndex].SwitchPrePosition = GetSwitchCurPosition(switchId);
/*道岔当前位置*/
SwitchDataStru[bufIndex].SwitchCurPosition = curPosition;
/*时间不变*/
}
else
{
/*超时*/
/*设置道岔之前位置*/
SwitchDataStru[bufIndex].SwitchPrePosition = GetSwitchCurPosition(switchId);
/*道岔当前位置 【挤岔】*/
SwitchDataStru[bufIndex].SwitchCurPosition = SWITCH_POSITION_JICHA;
/*时间不变*/
}
}
else
{
/*不做处理*/
}
}
}
else
{
/*不做处理*/
}
}
/*
* 功能描述: 设置指定ID单独道岔当前位置
* 参数说明: const UINT16 switchId, 道岔ID
* const UINT8 curPosition, 当前位置
* 返回值
*
*/
void SetSingleSwitchCurPosition(const UINT16 switchId, const UINT8 curPosition)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT8 moveTimeState = 0u;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (bufIndex < SWITCH_SUM_MAX)
{
if (0U < SwitchDataStru[bufIndex].SwitDriveStartCycNum)
{
/*有驱动设置驱动过标志*/
SetSwitchDrivedFlag(switchId, SWITCH_DRIVED_FLAG_YES);
}
else
{
; /*不处理*/
}
if ((SWITCH_POSITION_DINGWEI == curPosition) || (SWITCH_POSITION_FANWEI == curPosition))
{/* zt 删除单轨相关代码 2022-02-15 */
/*道岔当前位置*/
SwitchDataStru[bufIndex].SingleSwitchCurPosition = curPosition;
/*清除道岔开始动作时间*/
SetSwitchMoveStartCycNum(switchId,0u);
if(((SWITCH_POSITION_DINGWEI == curPosition) && (SWITCH_DRIVE_POS_DINGWEI == SwitchDataStru[bufIndex].switchLastValidDrvPos))
|| ((SWITCH_POSITION_FANWEI == curPosition) && (SWITCH_DRIVE_POS_FANWEI == SwitchDataStru[bufIndex].switchLastValidDrvPos)))
{
/*最近一次驱动位置和当前位置相同,认为驱动结束*/
SetSwitchDrivedFlag(switchId, SWITCH_DRIVED_FLAG_NO);
}
else
{
;
}
}
else if ((SWITCH_POSITION_SIKAI == curPosition) || (SWITCH_POSITION_MOVE == curPosition))
{
moveTimeState = SystemOverTimeCheck(GetSwitchMoveStartCycNum(switchId), GetSystemParaSwitchMoveCyc());
if (moveTimeState == CI_TIME_NO)
{
/*未设置动作时间*/
/*道岔当前位置*/
SwitchDataStru[bufIndex].SingleSwitchCurPosition = curPosition;
/*设置道岔开始动作时间*/
if (CI_TRUE == CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SWITCH, switchId))
{ /*只有具有本联锁控制权的道岔才设置道岔挤岔状态*/
/*设置道岔开始动作时间*/
SetSwitchMoveStartCycNum(switchId,Get2oo2CurCycleNum());
}
}
else if (moveTimeState == CI_TIME_IN)
{
/*计时中*/
/*道岔当前位置*/
SwitchDataStru[bufIndex].SingleSwitchCurPosition = curPosition;
/*时间不变*/
}
else
{
/*超时*/
/*道岔当前位置 【挤岔】*/
SwitchDataStru[bufIndex].SingleSwitchCurPosition = SWITCH_POSITION_JICHA;
/*时间不变*/
}
}
else if (SWITCH_POSITION_JICHA == curPosition)
{
SwitchDataStru[bufIndex].SingleSwitchCurPosition = SWITCH_POSITION_JICHA; /*修复相邻联锁无法复视挤岔状态问题——added by lq 2023.11.17*/
}
else
{
/*状态错误,不处理*/
}
}
else
{
/*不做处理*/
}
}
/*
* 功能描述: 获取指定ID道岔驱动位置
* 参数说明: const UINT16 switchId, 道岔ID
* 返回值 0: 获取数据失败
* >0: 驱动位置
*/
UINT8 GetSwitchDrivePostion(const UINT16 switchId)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT8 retVal = CI_ERROR;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (bufIndex < SWITCH_SUM_MAX)
{
retVal = SwitchDataStru[bufIndex].SwitchDrivePos;
}
else
{
retVal = CI_ERROR;
}
return retVal;
}
/*
* 功能描述: 设置指定ID道岔驱动位置
* 参数说明: const UINT16 switchId, 道岔ID
* const UINT8 drivePosition, 驱动位置
* 返回值
*
*/
void SetSwitchDrivePostion(const UINT16 switchId, const UINT8 drivePosition)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT16 bufIndex2 = 0u;/*双动道岔下标*/
UINT8 curDriverPos = 0u;
UINT8 singleSwitchCurPosition = 0U;
UINT16 switchOtherId = 0U; /*双动道岔另一道岔ID*/
UINT8 ciPattern = GetLocalCiPattern();
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
switchOtherId = GetDSwitchOtherId(switchId);
bufIndex2 = GetSwitchConfigBufIndex(switchOtherId); /*获取双动道岔数组下标*/
if (bufIndex < SWITCH_SUM_MAX)
{
if ((SWITCH_DRIVE_POS_DINGWEI == drivePosition) || (SWITCH_DRIVE_POS_FANWEI == drivePosition))
{/* zt 删除单轨相关代码 2022-02-15 */
/*当前驱动状态*/
curDriverPos = SwitchDataStru[bufIndex].SwitchDrivePos;
if (CI_PATTERN_FULL_ELECTRONIC == ciPattern)
{
singleSwitchCurPosition = GetSingleSwitchCurPosition(switchId);
}
else
{
singleSwitchCurPosition = GetSwitchCurPosition(switchId);
}
if (drivePosition != curDriverPos)
{/*道岔当前驱动无效或者驱动位置不等于最新驱动位置*/
if (((SWITCH_DRIVE_POS_DINGWEI == drivePosition) && (SWITCH_POSITION_DINGWEI != singleSwitchCurPosition))
|| ((SWITCH_DRIVE_POS_FANWEI == drivePosition) && (SWITCH_POSITION_FANWEI != singleSwitchCurPosition)))
{/*驱动定位且道岔不在定位或驱动反位且道岔不在反位*/
/*设置驱动位置*/
SwitchDataStru[bufIndex].SwitchDrivePos = drivePosition;
/*道岔驱动开始时间*/
SetSwitchDriveStartCycNum(switchId, Get2oo2CurCycleNum());
}
}
else
{/*驱动位置等于最新驱动位置*/
if (((SWITCH_DRIVE_POS_DINGWEI == drivePosition) && (SWITCH_POSITION_DINGWEI == singleSwitchCurPosition))
|| ((SWITCH_DRIVE_POS_FANWEI == drivePosition) && (SWITCH_POSITION_FANWEI == singleSwitchCurPosition)))
{/*已经驱动到位置*/
/*设置驱动无效*/
SwitchDataStru[bufIndex].SwitchDrivePos = SWITCH_DRIVE_POS_INVALID;
/*道岔驱动开始时间*/
SetSwitchDriveStartCycNum(switchId, 0U);
}
}
/*若存在双动道岔,则需要驱动*/
if ((SWITCH_SUM_MAX > switchOtherId) && (0U < switchOtherId) && (SWITCH_SUM_MAX > bufIndex2))
{
/*双动道岔当前驱动状态*/
curDriverPos = SwitchDataStru[bufIndex2].SwitchDrivePos;
if (CI_PATTERN_FULL_ELECTRONIC == ciPattern)
{
singleSwitchCurPosition = GetSingleSwitchCurPosition(switchOtherId);
}
else
{
singleSwitchCurPosition = GetSwitchCurPosition(switchOtherId);
}
if (drivePosition != curDriverPos)
{/*双动道岔当前驱动无效或者驱动位置不等于最新驱动位置*/
if (((SWITCH_DRIVE_POS_DINGWEI == drivePosition) && (SWITCH_POSITION_DINGWEI != singleSwitchCurPosition))
|| ((SWITCH_DRIVE_POS_FANWEI == drivePosition) && (SWITCH_POSITION_FANWEI != singleSwitchCurPosition)))
{/*驱动定位且道岔不在定位或驱动反位且道岔不在反位*/
/*设置驱动位置*/
SwitchDataStru[bufIndex2].SwitchDrivePos = drivePosition;
/*道岔驱动开始时间*/
SetSwitchDriveStartCycNum(switchOtherId, Get2oo2CurCycleNum());
}
}
else
{/*驱动位置等于最新驱动位置*/
if (((SWITCH_DRIVE_POS_DINGWEI == drivePosition) && (SWITCH_POSITION_DINGWEI == singleSwitchCurPosition))
|| ((SWITCH_DRIVE_POS_FANWEI == drivePosition) && (SWITCH_POSITION_FANWEI == singleSwitchCurPosition)))
{/*已经驱动到位置*/
/*设置驱动无效*/
SwitchDataStru[bufIndex2].SwitchDrivePos = SWITCH_DRIVE_POS_INVALID;
/*道岔驱动开始时间*/
SetSwitchDriveStartCycNum(switchOtherId, 0U);
}
}
}
}
else if (SWITCH_DRIVE_POS_INVALID == drivePosition)
{
SwitchDataStru[bufIndex].SwitchDrivePos = drivePosition; /*道岔驱动无效*/
SetSwitchDriveStartCycNum(switchId, 0u);/*道岔驱动开始动作时间清零*/
if (bufIndex2 < SWITCH_SUM_MAX)
{/*双动道岔*/
SwitchDataStru[bufIndex2].SwitchDrivePos = drivePosition;/*道岔驱动无效*/
SetSwitchDriveStartCycNum(GetDSwitchOtherId(switchId), 0u);/*双动道岔驱动开始动作时间清零*/
}
}
else
{
/*不做处理*/
}
}
else
{
/*不做处理*/
}
}
/*
* 功能描述: 获取指定ID道岔动作起始周期号
* 参数说明: const UINT16 switchId, 道岔ID
* 返回值 0: 获取数据失败
* >0: 动作起始周期号
*/
UINT32 GetSwitchMoveStartCycNum(const UINT16 switchId)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT32 retVal = CI_ERROR;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (bufIndex < SWITCH_SUM_MAX)
{
retVal = SwitchDataStru[bufIndex].SwitMoveStartCycNum;
}
else
{
retVal = CI_ERROR;
}
return retVal;
}
/*
* 功能描述: 设置指定ID道岔动作起始周期号
* 参数说明: const UINT16 switchId, 道岔ID
* const UINT32 moveStartCycNum, 动作起始周期号
* 返回值
*
*/
void SetSwitchMoveStartCycNum(const UINT16 switchId, const UINT32 moveStartCycNum)
{
UINT16 bufIndex = 0u; /*数组下标*/
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (bufIndex < SWITCH_SUM_MAX)
{
SwitchDataStru[bufIndex].SwitMoveStartCycNum = moveStartCycNum; /*道岔动作起始周期号*/
}
}
/*
* 功能描述: 获取指定ID道岔驱动起始周期号
* 参数说明: const UINT16 switchId, 道岔ID
* 返回值 0: 获取数据失败
* >0: 驱动起始周期号
*/
UINT32 GetSwitchDriveStartCycNum(const UINT16 switchId)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT32 retVal = CI_ERROR;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (bufIndex < SWITCH_SUM_MAX)
{
retVal = SwitchDataStru[bufIndex].SwitDriveStartCycNum;
}
else
{
retVal = CI_ERROR;
}
return retVal;
}
/*
* 功能描述: 设置指定ID道岔驱动起始周期号
* 参数说明: const UINT16 switchId, 道岔ID
* const UINT32 driveStartCycNum, 驱动起始周期号
* 返回值
*
*/
void SetSwitchDriveStartCycNum(const UINT16 switchId, const UINT32 driveStartCycNum)
{
UINT16 bufIndex = 0u; /*数组下标*/
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (bufIndex < SWITCH_SUM_MAX)
{
SwitchDataStru[bufIndex].SwitDriveStartCycNum = driveStartCycNum; /*道岔驱动起始周期号*/
}
else
{
/*不做处理*/
}
}
/*
* 功能描述: 获取指定ID道岔单操位置
* 参数说明: const UINT16 switchId, 道岔ID
* 返回值 0: 获取数据失败
* >0: 引导总锁状态
*/
UINT8 GetSwitchDanCaoPostition(const UINT16 switchId)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT8 retVal = CI_ERROR;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (bufIndex < SWITCH_SUM_MAX)
{
retVal = SwitchDataStru[bufIndex].SwitchDanCaoPostition;
}
else
{
retVal = CI_ERROR;
}
return retVal;
}
/*
* 功能描述: 设置指定ID道岔单操位置
* 参数说明: const UINT16 switchId, 道岔ID
* const UINT8 position, 道岔位置
* 返回值 0: 设置失败
* 1: 设置成功
*/
UINT8 SetSwitchDanCaoPosition(const UINT16 switchId, const UINT8 position)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT16 bufIndex2 = SWITCH_SUM_MAX;/*双动道岔下标*/
UINT16 otherSwitId = 0u;
UINT8 retVal = CI_SUCCESS;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (bufIndex >= SWITCH_SUM_MAX)
{
retVal = CI_ERROR;
}
if(CI_SUCCESS == retVal)
{
otherSwitId = GetDSwitchOtherId(switchId); /*获取另一道岔ID*/
if (otherSwitId > 0u)
{
bufIndex2 = GetSwitchConfigBufIndex(otherSwitId); /*获取双动道岔数组下标*/
if (bufIndex2 >= SWITCH_SUM_MAX)
{
retVal = CI_ERROR;
}
}
}
if(CI_SUCCESS == retVal)
{
if ((SWITCH_POSITION_DINGWEI == position) || (SWITCH_POSITION_FANWEI == position))
{/* zt 删除单轨相关代码 2022-02-15 */
SwitchDataStru[bufIndex].SwitchDanCaoPostition = position; /*道岔单操位置*/
if (bufIndex2 < SWITCH_SUM_MAX)
{
SwitchDataStru[bufIndex2].SwitchDanCaoPostition = position; /*双动道岔单操位置*/
}
retVal = CI_SUCCESS;
}
else if(SWITCH_POSITION_INVALID == position)
{
SwitchDataStru[bufIndex].SwitchDanCaoPostition = position; /*取消单操位置*/
if (bufIndex2 < SWITCH_SUM_MAX)
{
SwitchDataStru[bufIndex2].SwitchDanCaoPostition = position; /*取消双动单操位置*/
}
retVal = CI_SUCCESS;
}
else
{
retVal = CI_ERROR;
}
}
return retVal;
}
/*
* 功能描述: 获取指定ID道岔期望驱动位置
* 参数说明: const UINT16 switchId, 道岔ID
* 返回值 0: 获取数据失败
* >0: 驱动位置
*/
UINT8 GetSwitchExpDrvPosition(const UINT16 switchId)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT8 retVal = CI_ERROR;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (bufIndex < SWITCH_SUM_MAX)
{
retVal = SwitchDataStru[bufIndex].SwitchExpDrvPos;
}
return retVal;
}
/*
* 功能描述: 设置指定ID道岔期望驱动位置
* 参数说明: const UINT16 switchId, 道岔ID
* const UINT8 drivePosition, 驱动位置
* 返回值 0: 设置失败
* 1: 设置成功
*/
UINT8 SetSwitchExpDrvPosition(const UINT16 switchId, const UINT8 drivePosition)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT16 bufIndex2 = 0u;/*双动道岔下标*/
UINT16 otherSwitchId = 0u; /*联动道岔ID*/
UINT8 ohterCurSwitchPos = 0u; /*联动道岔当前位置*/
UINT8 ohterSwitchExpDrvPos = 0u; /*联动道岔期望驱动位置*/
UINT8 retVal = CI_ERROR;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
otherSwitchId = GetDSwitchOtherId(switchId); /*获取道岔ID*/
bufIndex2 = GetSwitchConfigBufIndex(otherSwitchId); /*获取双动道岔数组下标*/
if (bufIndex < SWITCH_SUM_MAX)
{
if ((SWITCH_DRIVE_POS_DINGWEI == drivePosition) || (SWITCH_DRIVE_POS_FANWEI == drivePosition))
{/* zt 删除单轨相关代码 2022-02-15 */
/*驱动无效可设置驱动*/
SwitchDataStru[bufIndex].SwitchExpDrvPos = drivePosition;
if (bufIndex2 < SWITCH_SUM_MAX)
{/*双动道岔*/
SwitchDataStru[bufIndex2].SwitchExpDrvPos = drivePosition;
}
retVal = CI_SUCCESS;/*可以无条件赋CI_SUCCESS,因为双动道岔另一道岔ID为0时(单动道岔),bufIndex2为SWITCH_SUM_MAX,也应为CI_SUCCESS*/
}
else if (SWITCH_DRIVE_POS_INVALID == drivePosition)
{
SwitchDataStru[bufIndex].SwitchExpDrvPos = drivePosition; /*道岔驱动无效*/
if (bufIndex2 < SWITCH_SUM_MAX)
{/*双动道岔*/
SwitchDataStru[bufIndex2].SwitchExpDrvPos = drivePosition;/*道岔驱动无效*/
}
retVal = CI_SUCCESS;/*可以无条件赋CI_SUCCESS,因为双动道岔另一道岔ID为0时(单动道岔),bufIndex2为SWITCH_SUM_MAX,也应为CI_SUCCESS*/
}
else
{
retVal = CI_ERROR;
}
}
else
{
retVal = CI_ERROR;
}
return retVal;
}
/*
* 功能描述: 获取指定ID道岔驱动状态
* 参数说明: const UINT16 switchId, 道岔ID
* 返回值 0: 获取数据失败
* >0: 驱动状态
*/
UINT8 GetSwitchDrivingState(const UINT16 switchId)
{
UINT8 retVal = CI_ERROR;
UINT16 bufIndex = 0u; /*数组下标*/
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (bufIndex < SWITCH_SUM_MAX)
{
retVal = SwitchDataStru[bufIndex].switchDrivingState;
}
return retVal;
}
/*
* 功能描述: 设置指定ID道岔驱动状态
* 参数说明: const UINT16 switchId, 道岔ID
* const UINT8 switchDrivingState, 驱动状态
* 返回值
*
*/
void SetSwitchDrivingState(const UINT16 switchId, const UINT8 switchDrivingState)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT16 bufIndex2 = 0u; /*数组下标*/
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
bufIndex2 = GetSwitchConfigBufIndex(GetDSwitchOtherId(switchId)); /*获取双动道岔数组下标*/
if (bufIndex < SWITCH_SUM_MAX)
{
SwitchDataStru[bufIndex].switchDrivingState = switchDrivingState;
if (bufIndex2 < SWITCH_SUM_MAX)
{/*双动道岔*/
SwitchDataStru[bufIndex2].switchDrivingState = switchDrivingState;/*道岔驱动无效*/
}
}
}
/*
* 功能描述: 设置指定ID道岔之前希望驱动位置
* 参数说明: const UINT16 switchId, 道岔ID
* const UINT8 drivePosition, 驱动位置
* 返回值
*
*/
void SetSwitchPreExpDrvPosition(const UINT16 switchId, const UINT8 drivePosition)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT16 bufIndex2 = 0u;/*双动道岔下标*/
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
bufIndex2 = GetSwitchConfigBufIndex(GetDSwitchOtherId(switchId)); /*获取双动道岔数组下标*/
if (bufIndex < SWITCH_SUM_MAX)
{
if ((SWITCH_DRIVE_POS_DINGWEI == drivePosition) || (SWITCH_DRIVE_POS_FANWEI == drivePosition))
{/* zt 删除单轨相关代码 2022-02-15 */
/*驱动无效可设置驱动*/
SwitchDataStru[bufIndex].switchPreExpDrvPos = drivePosition;
if (bufIndex2 < SWITCH_SUM_MAX)
{/*双动道岔*/
SwitchDataStru[bufIndex2].switchPreExpDrvPos = drivePosition;
}
}
else if (SWITCH_DRIVE_POS_INVALID == drivePosition)
{
SwitchDataStru[bufIndex].switchPreExpDrvPos = drivePosition; /*道岔驱动无效*/
if (bufIndex2 < SWITCH_SUM_MAX)
{/*双动道岔*/
SwitchDataStru[bufIndex2].switchPreExpDrvPos = drivePosition;/*道岔驱动无效*/
}
}
else
{
/*不做处理*/
}
}
else
{
/*不做处理*/
}
}
/*
* 功能描述: 获取指定ID道岔之前期望驱动位置
* 参数说明: const UINT16 switchId, 道岔ID
* 返回值 0: 获取数据失败
* >0: 驱动位置
*/
UINT8 GetSwitchPreExpDrvPosition(const UINT16 switchId)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT8 retVal = CI_ERROR;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (bufIndex < SWITCH_SUM_MAX)
{
retVal = SwitchDataStru[bufIndex].switchPreExpDrvPos;
}
return retVal;
}
/*
* 功能描述: 设置指定ID道岔驱动超时位置
* 参数说明: const UINT16 switchId, 道岔ID
* const UINT8 drivePosition, 驱动位置
* 返回值
*
*/
void SetSwitchDrivOvtmDrvPosition(const UINT16 switchId, const UINT8 drivePosition)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT16 bufIndex2 = 0u;/*双动道岔下标*/
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
bufIndex2 = GetSwitchConfigBufIndex(GetDSwitchOtherId(switchId)); /*获取双动道岔数组下标*/
if (bufIndex < SWITCH_SUM_MAX)
{
if ((SWITCH_DRIVE_POS_DINGWEI == drivePosition) || (SWITCH_DRIVE_POS_FANWEI == drivePosition) || (SWITCH_DRIVE_POS_INVALID == drivePosition))
{/* zt 删除单轨相关代码 2022-02-15 */
/*驱动无效可设置驱动*/
SwitchDataStru[bufIndex].switchDrivOvtmDrvPos = drivePosition;
if (bufIndex2 < SWITCH_SUM_MAX)
{/*双动道岔*/
SwitchDataStru[bufIndex2].switchDrivOvtmDrvPos = drivePosition;
}
}
else
{
/*不做处理*/
}
}
else
{
/*不做处理*/
}
}
/*
* 功能描述: 获取指定ID道岔驱动超时位置
* 参数说明: const UINT16 switchId, 道岔ID
* 返回值 0: 获取数据失败
* >0: 驱动位置
*/
UINT8 GetSwitchDrivOvtmDrvPosition(const UINT16 switchId)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT8 retVal = CI_ERROR;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (bufIndex < SWITCH_SUM_MAX)
{
retVal = SwitchDataStru[bufIndex].switchDrivOvtmDrvPos;
}
return retVal;
}
/*
* 功能描述: 设置指定ID道岔故障状态
* 参数说明: const UINT16 switchId, 道岔ID
* 返回值 0: 设置数据失败
* >0: 道岔故障状态
*/
UINT8 SetSwitchFaultState(const UINT16 switchId,const UINT8 faultState)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT8 retVal = CI_ERROR;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (bufIndex < SWITCH_SUM_MAX)
{
if ((SWITCH_FAULT_STATE_YES == faultState) || (SWITCH_FAULT_STATE_NO == faultState))
{
/*道岔故障状态*/
SwitchDataStru[bufIndex].switchFaultState = faultState;
retVal = CI_SUCCESS;
}
else
{
retVal = CI_ERROR;
}
}
else
{
retVal = CI_ERROR;
}
return retVal;
}
/*
* 功能描述: 获取指定ID道岔故障状态
* 参数说明: const UINT16 switchId, 道岔ID
* 返回值 0: 获取数据失败
* >0: 道岔故障状态
*/
UINT8 GetSwitchFaultState(const UINT16 switchId)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT8 retVal = CI_ERROR;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (bufIndex < SWITCH_SUM_MAX)
{
retVal = SwitchDataStru[bufIndex].switchFaultState;
}
return retVal;
}
/* zt 删除单轨相关代码 2022-02-15 */
/*
* 功能描述: 设置指定ID道岔可绕状态
* 参数说明: const UINT16 switchId, 道岔ID
* 返回值 0: 设置数据失败
* >0: 设置数据成功
*/
UINT8 SetSwitchKRState(const UINT16 switchId, const UINT8 switchKRState)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT8 retVal = CI_ERROR;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (bufIndex < SWITCH_SUM_MAX)
{
if ((SWITCH_KERAO_STATE_YES == switchKRState) || (SWITCH_KERAO_STATE_NO == switchKRState))
{
/*道岔可绕状态*/
SwitchDataStru[bufIndex].switchKRState = switchKRState;
retVal = CI_SUCCESS;
}
else
{
retVal = CI_ERROR;
}
}
else
{
retVal = CI_ERROR;
}
return retVal;
}
/*
* 功能描述: 获取指定ID道岔可绕状态
* 参数说明: const UINT16 switchId, 道岔ID
* 返回值 0: 获取数据失败
* >0: 道岔可绕状态
*/
UINT8 GetSwitchKRState(const UINT16 switchId)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT8 retVal = CI_ERROR;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (bufIndex < SWITCH_SUM_MAX)
{
retVal = SwitchDataStru[bufIndex].switchKRState;
}
return retVal;
}
/* zt 删除单轨相关代码 2022-02-15 */
/*
* 功能描述: 设置指定ID道岔最近一次的有效驱动位置
* 参数说明: const UINT16 switchId, 道岔ID
* const UINT8 drivePosition, 驱动位置
* 返回值 0: 设置失败
* 1: 设置成功
*/
UINT8 SetSwitchLastValidDrvPos(const UINT16 switchId, const UINT8 drivePosition)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT8 retVal = CI_ERROR;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (bufIndex < SWITCH_SUM_MAX)
{
if ((SWITCH_DRIVE_POS_DINGWEI == drivePosition) || (SWITCH_DRIVE_POS_FANWEI == drivePosition))
{
/*驱动定位或反位*/
SwitchDataStru[bufIndex].switchLastValidDrvPos = drivePosition;
retVal = CI_SUCCESS;
}
else
{
retVal = CI_ERROR;
}
}
else
{
retVal = CI_ERROR;
}
return retVal;
}
/*
* 功能描述: 获取指定ID道岔最近一次的有效驱动位置
* 参数说明: const UINT16 switchId, 道岔ID
* 返回值 0: 获取数据失败
* >0: 最近一次的有效驱动位置
*/
UINT8 GetSwitchLastValidDrvPos(const UINT16 switchId)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT8 retVal = CI_ERROR;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (bufIndex < SWITCH_SUM_MAX)
{
retVal = SwitchDataStru[bufIndex].switchLastValidDrvPos;
}
return retVal;
}
/*
* 功能描述: 设置指定ID道岔最近一次有效驱动周期号
* 参数说明: const UINT16 switchId, 道岔ID
* const UINT32 driveStartCycNum, 驱动起始周期号
* 返回值 0: 设置失败
* 1: 设置成功
*/
UINT8 SetSwitchLastValidPosDrivCycNum(const UINT16 switchId, const UINT32 driveStartCycNum)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT8 retVal = CI_ERROR;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (bufIndex < SWITCH_SUM_MAX)
{
SwitchDataStru[bufIndex].switchLastValidDrvPosCycleNum = driveStartCycNum; /*道岔驱动起始周期号*/
retVal = CI_SUCCESS;
}
else
{
retVal = CI_ERROR;
}
return retVal;
}
/*
* 功能描述: 获取指定ID道岔最近一次有效驱动起始周期号
* 参数说明: const UINT16 switchId, 道岔ID
* 返回值 0: 获取数据失败
* >0: 驱动起始周期号
*/
UINT32 GetSwitchLastValDrvPosStartCyc(const UINT16 switchId)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT32 retVal = CI_ERROR;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (bufIndex < SWITCH_SUM_MAX)
{
retVal = SwitchDataStru[bufIndex].switchLastValidDrvPosCycleNum;
}
else
{
retVal = CI_ERROR;
}
return retVal;
}
/*
* 功能描述: 获取指定ID道 岔征用该道岔的保护区段ID
* 参数说明: const UINT16 switchId, 道岔ID
* 返回值 0: 道岔未被征用
* >0: 征用该道岔的保护区段ID
*/
UINT16 GetSwitchBelongOverlapId(const UINT16 switchId)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT16 retVal = CI_ERROR;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (bufIndex < SWITCH_SUM_MAX)
{
retVal = SwitchDataStru[bufIndex].UsingBelongOverlapId;
}
else
{
retVal = CI_ERROR;
}
return retVal;
}
/*
* 功能描述: 设置指定ID道岔定反后继电器吸起有效周期号
* 参数说明: const UINT16 switchId, 道岔ID
* const UINT32 validStartCycNum, 有效起始周期号
* 返回值 0: 设置失败
* 1: 设置成功
*/
UINT8 SetSwitchDFHRelayValidCycNum(const UINT16 switchId, const UINT32 validStartCycNum)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT8 retVal = CI_ERROR;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (bufIndex < SWITCH_SUM_MAX)
{
SwitchDataStru[bufIndex].DFHRelayValidCycNum = validStartCycNum; /*道岔有效起始周期号*/
retVal = CI_SUCCESS;
}
else
{
retVal = CI_ERROR;
}
return retVal;
}
/*
* 功能描述: 获取指定ID道岔定反后继电器吸起有效周期号
* 参数说明: const UINT16 switchId, 道岔ID
* 返回值 0: 获取数据失败
* >0: 驱动起始周期号
*/
UINT32 GetSwitchDFHRelayValidCycNum(const UINT16 switchId)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT32 retVal = CI_ERROR;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (bufIndex < SWITCH_SUM_MAX)
{
retVal = SwitchDataStru[bufIndex].DFHRelayValidCycNum;
}
else
{
retVal = CI_ERROR;
}
return retVal;
}
/*
* 功能描述: 设置指定ID单独道岔定反后继电器吸起有效周期号
* 参数说明: const UINT16 switchId, 道岔ID
* const UINT32 driveStartCycNum, 驱动起始周期号
* 返回值 0: 设置失败
* 1: 设置成功
*/
UINT8 SetSigleSwitchDFHRelayValCyc(const UINT16 switchId, const UINT32 driveStartCycNum)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT8 retVal = CI_ERROR;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (bufIndex < SWITCH_SUM_MAX)
{
SwitchDataStru[bufIndex].SigleDFHRelayValidCycNum = driveStartCycNum; /*道岔驱动起始周期号*/
retVal = CI_SUCCESS;
}
else
{
retVal = CI_ERROR;
}
return retVal;
}
/*
* 功能描述: 获取指定ID单独道岔定反后继电器吸起有效周期号
* 参数说明: const UINT16 switchId, 道岔ID
* 返回值 0: 获取数据失败
* >0: 驱动起始周期号
*/
UINT32 GetSigleSwitchDFHRelayValCyc(const UINT16 switchId)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT32 retVal = CI_ERROR;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (bufIndex < SWITCH_SUM_MAX)
{
retVal = SwitchDataStru[bufIndex].SigleDFHRelayValidCycNum;
}
else
{
retVal = CI_ERROR;
}
return retVal;
}
/*
* 功能描述: 设置指定ID道岔允操继电器吸起有效周期号
* 参数说明: const UINT16 switchId, 道岔ID
* const UINT32 validStartCycNum, 有效起始周期号
* 返回值 0: 设置失败
* 1: 设置成功
*/
UINT8 SetSwitchYCRelayValidCycNum(const UINT16 switchId, const UINT32 validStartCycNum)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT8 retVal = CI_ERROR;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (bufIndex < SWITCH_SUM_MAX)
{
SwitchDataStru[bufIndex].YCRelayValidCycNum = validStartCycNum; /*道岔有效起始周期号*/
retVal = CI_SUCCESS;
}
else
{
retVal = CI_ERROR;
}
return retVal;
}
/*
* 功能描述: 获取指定ID道岔允操继电器吸起有效周期号
* 参数说明: const UINT16 switchId, 道岔ID
* 返回值 0: 获取数据失败
* >0: 驱动起始周期号
*/
UINT32 GetSwitchYCRelayValidCycNum(const UINT16 switchId)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT32 retVal = CI_ERROR;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (bufIndex < SWITCH_SUM_MAX)
{
retVal = SwitchDataStru[bufIndex].YCRelayValidCycNum;
}
else
{
retVal = CI_ERROR;
}
return retVal;
}
/*
* 功能描述: 设置指定ID单独道岔允操继电器吸起有效周期号
* 参数说明: const UINT16 switchId, 道岔ID
* const UINT32 driveStartCycNum, 驱动起始周期号
* 返回值 0: 设置失败
* 1: 设置成功
*/
UINT8 SetSingleSwitchYCRelayValCyc(const UINT16 switchId, const UINT32 driveStartCycNum)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT8 retVal = CI_ERROR;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (bufIndex < SWITCH_SUM_MAX)
{
SwitchDataStru[bufIndex].SigleYCRelayValidCycNum = driveStartCycNum; /*道岔驱动起始周期号*/
retVal = CI_SUCCESS;
}
else
{
retVal = CI_ERROR;
}
return retVal;
}
/*
* 功能描述: 获取指定ID单独道岔允操继电器吸起有效周期号
* 参数说明: const UINT16 switchId, 道岔ID
* 返回值 0: 获取数据失败
* >0: 驱动起始周期号
*/
UINT32 GetSingleSwitchYCRelayValCyc(const UINT16 switchId)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT32 retVal = CI_ERROR;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (bufIndex < SWITCH_SUM_MAX)
{
retVal = SwitchDataStru[bufIndex].SigleYCRelayValidCycNum;
}
else
{
retVal = CI_ERROR;
}
return retVal;
}
/*
* 功能描述: 获取联络线道岔单锁状态
* 参数说明: const UINT16 switchId, 道岔ID
* 返回值 0: 获取数据失败
* >0: 道岔单锁状态
*/
UINT8 GetConnetSwitchDsState(const UINT16 switchId)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT8 retVal = CI_ERROR;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (bufIndex < SWITCH_SUM_MAX)
{
retVal = SwitchDataStru[bufIndex].ConnetSwitchDsState;
}
return(retVal);
}
/*
* 功能描述: 设置联络线道岔单锁状态
* 参数说明: const UINT16 switchId, 道岔ID
* const UINT8 dsState 单锁状态
* 返回值
*
*/
void SetConnetSwitchDsState(const UINT16 switchId, const UINT8 dsState)
{
UINT16 bufIndex = 0u; /*数组下标*/
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (bufIndex < SWITCH_SUM_MAX)
{
if((CONNECT_SWITCH_DANSUO_YES == dsState) || (CONNECT_SWITCH_DANSUO_NO == dsState))
{
SwitchDataStru[bufIndex].ConnetSwitchDsState = dsState;
}
}
}
/*
* 功能描述: 获取联络线道岔旁路状态
* 参数说明: const UINT16 switchId, 道岔ID
* 返回值 0: 获取数据失败
* >0: 道岔旁路状态
*/
UINT8 GetConnetSwitchByPassState(const UINT16 switchId)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT8 retVal = CI_ERROR;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (bufIndex < SWITCH_SUM_MAX)
{
retVal = SwitchDataStru[bufIndex].SwitchByPassState;
}
return(retVal);
}
/*
* 功能描述: 设置联络线道岔旁路状态
* 参数说明: const UINT16 switchId, 道岔ID
* const UINT8 byPassState 旁路状态
* 返回值
*
*/
void SetConnetSwitchByPassState(const UINT16 switchId, const UINT8 byPassState)
{
UINT16 bufIndex = 0u; /*数组下标*/
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (bufIndex < SWITCH_SUM_MAX)
{
if((SWITCH_BYPASS_YES == byPassState) || (SWITCH_BYPASS_NO == byPassState))
{
SwitchDataStru[bufIndex].SwitchByPassState = byPassState;
}
}
}
/*
* 功能描述: 获取联络线道岔是否已经向ATS报警的标志
* 参数说明: const UINT16 switchId, 道岔ID
* 返回值 0: 获取数据失败
* >0: 是否已经向ATS报警的标志
*/
UINT8 GetCiToAtsByPassNoCancelFlag(const UINT16 switchId)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT8 retVal = CI_ERROR;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (bufIndex < SWITCH_SUM_MAX)
{
retVal = SwitchDataStru[bufIndex].CiToAtsSwitchByPassNoCancelFlag;
}
return(retVal);
}
/*
* 功能描述: 设置联络线道岔是否已经向ATS报警的标志
* 参数说明: const UINT16 switchId, 道岔ID
* const UINT8 ciToAtsSendFlag 是否发送的标志
* 返回值
*
*/
void SetCiToAtsByPassNoCancelFlag(const UINT16 switchId, const UINT8 ciToAtsSendFlag)
{
UINT16 bufIndex = 0u; /*数组下标*/
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (bufIndex < SWITCH_SUM_MAX)
{
if ((CI_ATS_SW_BYPASS_NOCANCEL_YES == ciToAtsSendFlag) || (CI_ATS_SW_BYPASS_NOCANCEL_NO == ciToAtsSendFlag))
{
SwitchDataStru[bufIndex].CiToAtsSwitchByPassNoCancelFlag = ciToAtsSendFlag;
}
}
}
/*
* 功能描述: 获取本控区所有道岔状态
* 参数说明:DQU_POINT_STATUS_STRU* pSwitchInfo, 道岔状态
* 返回值 : 成功-道岔数量 失败-UINT16_MAX
*
*/
UINT8 GetLocalSwitchState(DQU_POINT_STATUS_STRU* pSwitchInfo)
{
UINT8 cRetVal = UINT8_MAX;
UINT8 cSwitchSum = 0u;
UINT16 wLocalSwitchSum = SWITCH_SUM_MAX;
UINT16 wSwitchId = 0u;
UINT8 cSwitchState = SWITCH_POSITION_INVALID;
UINT8 cEmapSwitchState = EMAP_POINT_STATUS_LOSE;
UINT8 cLocalCiId = 0u; /*本地联锁ID*/
UINT8 cBelongCiId = 0u;
UINT16 ii = 0u;
wLocalSwitchSum = GetSwitchCurSum();
cLocalCiId = GetSystemParaLocalCiId(); /*获取本机联锁ID*/
if ((NULL != pSwitchInfo) && (UINT8_MAX > wLocalSwitchSum) && (0u != cLocalCiId))
{
for (ii = 0u; ii < wLocalSwitchSum; ii++)
{
wSwitchId = GetSwitchId(ii);
cBelongCiId = GetSwitchBelongCiId(wSwitchId); /*获取进路所属联锁ID*/
if ((0u == wSwitchId) || (SWITCH_SUM_MAX <= wSwitchId) || (cBelongCiId != cLocalCiId))
{
; /* 无处理 */
}
else
{
/* 获取道岔当前位置 */
cSwitchState = GetSwitchCurPosition(wSwitchId);
if (SWITCH_POSITION_DINGWEI == cSwitchState)
{
cEmapSwitchState = EMAP_POINT_STATUS_MAIN;
}
else if(SWITCH_POSITION_FANWEI == cSwitchState)
{
cEmapSwitchState = EMAP_POINT_STATUS_SIDE;
}
else
{
/* 其他位置认为道岔不连通 */
cEmapSwitchState = EMAP_POINT_STATUS_LOSE;
}
pSwitchInfo[cSwitchSum].PointId = wSwitchId;
pSwitchInfo[cSwitchSum].PointStatus = cEmapSwitchState;
pSwitchInfo[cSwitchSum].PointExpectedStatus = cEmapSwitchState;
cSwitchSum++;
}
}
cRetVal = cSwitchSum;
}
else
{
; /* 返回失败 */
}
return cRetVal;
}
/*
* 功能描述:设置道岔定/反位测试处理逻辑总调函数,根据传入命令类型(定位或者反位测试)执行相关逻辑判断
* 参数说明:const UINT8 chCmdType 命令类型
* 备注:cgh-合并CID-3037-6:。
*/
void SetSwitchTestLogicManage(const UINT8 chCmdType)
{
UINT16 switchCurSum = 0u;
UINT8 localCiId = 0u;
UINT8 SwitchBelongCiId = 0u;
UINT16 CycNum = 0u;
UINT16 switchId = 0u;
UINT8 chRtnTemp = 0u;
UINT8 chSwitchTestFlag = CI_ERROR;
/*函数故障码*/
UINT8 const functionId = EFUNC_SWITCHTESTLOGIC;
UINT8 retValue = 0U;
switchCurSum = GetSwitchCurSum(); /*获取道岔总数*/
localCiId = GetSystemParaLocalCiId(); /*获取本机联锁ID*/
if (ATS_CMD_SWITCH_DINGWEI_TEST_TWO == chCmdType)
{
/*道岔定位测试相关处理*/
for (CycNum = 0u; CycNum < switchCurSum; CycNum++)
{
chSwitchTestFlag = CI_ERROR;
switchId = GetSwitchId(CycNum); /*获取道岔ID*/
SwitchBelongCiId = GetSwitchBelongCiId(switchId); /*获取道岔所属联锁ID*/
if (SwitchBelongCiId == localCiId)
{
chRtnTemp = SetSwitchPositionLogicProcess(switchId, SWITCH_POSITION_DINGWEI, ATS_CMD_SWITCH_DINGWEI_TEST_TWO, &chSwitchTestFlag);
if (CI_SUCCESS == chRtnTemp)
{ /*成功*/
retValue = SetSwitchDanCaoPosition(switchId, SWITCH_POSITION_DINGWEI); /*设置单操定位标志*/
if (CI_ERROR == retValue)
{
/*设置道岔单操位置错误*/
}
}
else
{ /*失败*/
if (CI_ERROR == chSwitchTestFlag)
{
/*添加记录错误码代码*/
SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, switchId, ETYPE_SWT_MOVE_STATE, SWITCH_MOVE_FAIL, ESEND_LEVEL_ATS);
}
else
{
; /*由道岔定/反位测试使函数SetSwitchPositionLogicProcess返回的失败,不进行报警*/
}
}
}
}
}
else if (ATS_CMD_SWITCH_FANWEI_TEST_TWO == chCmdType)
{
/*道岔反位测试相关处理*/
for (CycNum = 0u; CycNum < switchCurSum; CycNum++)
{
switchId = GetSwitchId(CycNum); /*获取道岔ID*/
SwitchBelongCiId = GetSwitchBelongCiId(switchId); /*获取道岔所属联锁ID*/
if (SwitchBelongCiId == localCiId)
{
chRtnTemp = SetSwitchPositionLogicProcess(switchId, SWITCH_POSITION_FANWEI, ATS_CMD_SWITCH_FANWEI_TEST_TWO, &chSwitchTestFlag);
if (CI_SUCCESS == chRtnTemp)
{ /*成功*/
retValue = SetSwitchDanCaoPosition(switchId, SWITCH_POSITION_FANWEI); /*设置单操反位标志*/
if (CI_ERROR == retValue)
{
/*设置道岔单操位置错误*/
}
}
else
{ /*失败*/
if (CI_ERROR == chSwitchTestFlag)
{
/*添加记录错误码代码*/
SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, switchId, ETYPE_SWT_MOVE_STATE, SWITCH_MOVE_FAIL, ESEND_LEVEL_ATS);
}
else
{
; /*由道岔定/反位测试使函数SetSwitchPositionLogicProcess返回的失败,不进行报警*/
}
}
}
}
}
else
{
; /*非道岔定位/反位测试处理命令,不响应*/
}
}
/*
* 功能描述: 获取指定ID道岔立即向ATS报警信息
* 参数说明: const UINT16 switchId, 道岔ID
* 返回值 SWITCH_POSITION_JICHA: 道岔挤岔
* SWITCH_POSITION_SUDDEN_JICHA: 道岔静态红闪
* * SWITCH_POSITION_DYNAMIC_JICHA: 道岔静态红闪
* 其他值:单独道岔当前位置
* by cgh 20230919 仅用于向ATS发送道岔挤岔报警,不影响内部逻辑
*/
UINT8 GetSwitchPrompylyAlarmInfo(const UINT16 wSwitchId)
{
UINT8 retVal = 0U;
UINT32 dwSwitchDriveStartCycNum = 0U;/*道岔驱动起始周期号*/
UINT32 dwSwitchMoveStartCycNum = 0U;/*道岔移动起始周期号*/
UINT8 chSingleSwitchCurPosition = 0U;/*道岔当前有效位置*/
UINT32 dwSwitchDriveCycleCount = 0U;/*道岔驱动超限周期数*/
UINT8 chTimeState = 0U;/*驱动超时检查结果*/
UINT8 chSwitch = 0U;
UINT8 chSwitchDrivedFlag = 0U;/*道岔驱动过标志*/
chSwitch = GetCiFunctionSwitchConfig(FUNC_SWITCH_SHIBIAO_PROMPTLY_ALARM);
dwSwitchDriveCycleCount = GetSystemParaSwitchDriveCyc();
if (wSwitchId < SWITCH_SUM_MAX)
{
dwSwitchDriveStartCycNum = GetSwitchDriveStartCycNum(wSwitchId);
dwSwitchMoveStartCycNum = GetSwitchMoveStartCycNum(wSwitchId);
chSingleSwitchCurPosition = GetSingleSwitchCurPosition(wSwitchId);
chSwitchDrivedFlag = GetSwitchDrivedFlag(wSwitchId);
retVal = chSingleSwitchCurPosition;
if(FUNC_SWITCH_ON == chSwitch)
{
if (0U == dwSwitchDriveStartCycNum)
{
/*道岔驱动起始周期号为0,但道岔当前位置不为定位或者反位,此时若没驱动过认为道岔静态红闪(1DQJ未动作),驱动过认为动态红闪*/
if ((SWITCH_POSITION_DINGWEI != chSingleSwitchCurPosition) && (SWITCH_POSITION_FANWEI != chSingleSwitchCurPosition))
{
if (SWITCH_DRIVED_FLAG_YES == chSwitchDrivedFlag)
{
if (SWITCH_POSITION_JICHA == chSingleSwitchCurPosition)
{
retVal = SWITCH_POSITION_DYNAMIC_JICHA;
}
else
{
; /*被驱动过但是四开不报警*/
}
}
else
{
retVal = SWITCH_POSITION_SUDDEN_JICHA;
}
}
else
{
/*道岔当前位置为定位或者反位*/
}
}
else
{
chTimeState = SystemOverTimeCheck(dwSwitchDriveStartCycNum, dwSwitchDriveCycleCount);
if (CI_TIME_OUT == chTimeState)
{
retVal = SWITCH_POSITION_DYNAMIC_JICHA;
}
else
{
; /*驱动不超时不报警*/
}
}
}
else
{
if (SWITCH_POSITION_JICHA == chSingleSwitchCurPosition)
{
if (SWITCH_DRIVED_FLAG_YES == chSwitchDrivedFlag)
{
retVal = SWITCH_POSITION_DYNAMIC_JICHA;
}
else
{
retVal = SWITCH_POSITION_SUDDEN_JICHA; /*1、复式相邻联锁的道岔挤岔,此时无移动中周期2、无驱动四开超时*/
}
}
else
{
; /*其他状态*/
}
}
}
else
{
retVal = SWITCH_POSITION_JICHA;
}
return retVal;
}
/*
* 功能描述: 获取指定ID联络线道岔旁路未及时取消起始周期
* 参数说明: const UINT16 switchId, 道岔ID
* 返回值 0: 获取数据失败
* >0: 联络线道岔旁路未及时取消起始周期号
*/
UINT32 GetSwitchBypassStartCycNum(const UINT16 switchId)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT32 retVal = CI_ERROR;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (bufIndex < SWITCH_SUM_MAX)
{
retVal = SwitchDataStru[bufIndex].SwitchBypassStartCycNum;
}
else
{
retVal = CI_ERROR;
}
return retVal;
}
/*
* 功能描述: 设置指定ID联络线道岔旁路未及时取消起始周期
* 参数说明: const UINT16 switchId, 道岔ID
* const UINT32 bypassStartCycNum, 联络线道岔旁路未及时取消起始周期号
* 返回值
*
*/
void SetSwitchBypassStartCycNum(const UINT16 switchId, const UINT32 bypassStartCycNum)
{
UINT16 bufIndex = 0u; /*数组下标*/
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (bufIndex < SWITCH_SUM_MAX)
{
SwitchDataStru[bufIndex].SwitchBypassStartCycNum = bypassStartCycNum; /*联络线道岔旁路未及时取消起始周期号*/
}
else
{
/*不做处理*/
}
}
/*
* 功能描述: 获取道岔驱动过标志
* 参数说明: const UINT16 switchId, 道岔ID
* 返回值 0: 获取数据失败
* >0: 道岔驱动过标志
*/
UINT8 GetSwitchDrivedFlag(const UINT16 switchId)
{
UINT16 bufIndex = 0U; /*数组下标*/
UINT8 retVal = CI_ERROR;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (bufIndex < SWITCH_SUM_MAX)
{
retVal = SwitchDataStru[bufIndex].chSwitchDrivedFlag;
}
else
{
/*不做处理*/
}
return(retVal);
}
/*
* 功能描述: 设置道岔驱动过标志
* 参数说明: const UINT16 switchId, 道岔ID
* const UINT8 chSwitchDrivedFlag 道岔驱动过标志
* 返回值
*
*/
void SetSwitchDrivedFlag(const UINT16 switchId, const UINT8 chSwitchDrivedFlag)
{
UINT16 bufIndex = 0u; /*数组下标*/
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (bufIndex < SWITCH_SUM_MAX)
{
if ((SWITCH_DRIVED_FLAG_YES == chSwitchDrivedFlag) || (SWITCH_DRIVED_FLAG_NO == chSwitchDrivedFlag))
{
SwitchDataStru[bufIndex].chSwitchDrivedFlag = chSwitchDrivedFlag;
}
else
{
/*不做处理*/
}
}
else
{
/*不做处理*/
}
}
/*
* 功能描述: 获取道岔挤岔状态
* 参数说明: const UINT16 switchId, 道岔ID
* 返回值 0: 获取数据失败
* >0: 道岔挤岔状态
*/
UINT8 GetSwitchJichaState(const UINT16 switchId)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT8 retVal = CI_ERROR;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (SWITCH_SUM_MAX > bufIndex)
{
retVal = SwitchDataStru[bufIndex].chSwitchJichaState;
}
else
{
;
}
return retVal;
}
/*
* 功能描述: 设置道岔挤岔状态
* 参数说明: const UINT16 switchId, 道岔ID
* const UINT8 dsState 挤岔状态
* 返回值
*
*/
void SetSwitchJichaState(const UINT16 switchId, const UINT8 chJichaState)
{
UINT16 bufIndex = 0u; /*数组下标*/
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (SWITCH_SUM_MAX > bufIndex)
{
if ((SWITCH_POSITION_DYNAMIC_JICHA == chJichaState) || (SWITCH_POSITION_SUDDEN_JICHA == chJichaState))
{
SwitchDataStru[bufIndex].chSwitchJichaState = chJichaState;
}
else
{
SwitchDataStru[bufIndex].chSwitchJichaState = 0U;;
}
}
else
{
;
}
}
/*
* 功能描述:获取道岔征用状态
* 参数说明:const UINT16 wSwitchId 道岔ID
* 返 回 值:0 获取数据失败
* 0x11 未征用
* 0x22 征用
* 0x44 申请征用
* 0x88 申请取消征用
* Created By LQ 2024.12.05
*/
UINT8 GetSwitchUsingState(const UINT16 wSwitchId)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT8 retVal = CI_ERROR;
bufIndex = GetSwitchConfigBufIndex(wSwitchId); /*获取道岔数组下标*/
if (SWITCH_SUM_MAX > bufIndex)
{
retVal = SwitchDataStru[bufIndex].cSwitchUsingState;
}
else
{
;
}
return retVal;
}
/*
* 功能描述:设置道岔征用状态
* 参数说明:const UINT16 wSwitchId 道岔ID
* const UINT8 cSwUsingState 征用状态
* const UINT16 wOverlapId 保护区段ID
* 返 回 值:无
* Created By LQ 2024.12.05
*/
void SetSwitchUsingState(const UINT16 wSwitchId, const UINT8 cSwUsingState, const UINT16 wOverlapId)
{
UINT16 wSwitchIndex = 0U; /*道岔数组下标*/
wSwitchIndex = GetSwitchConfigBufIndex(wSwitchId); /*获取道岔数组下标*/
if ((SWITCH_SUM_MAX > wSwitchIndex)
&& ((SWITCH_USING_NO == cSwUsingState) || (SWITCH_USING_YES == cSwUsingState) || (SWITCH_USING_APPLY == cSwUsingState) || (SWITCH_USING_CANCEL == cSwUsingState)))
{
if (SWITCH_USING_NO == cSwUsingState)
{
if ((wOverlapId == SwitchDataStru[wSwitchIndex].UsingBelongOverlapId) || (0U == wOverlapId))
{
SwitchDataStru[wSwitchIndex].UsingBelongOverlapId = 0U;
SwitchDataStru[wSwitchIndex].cSwitchUsingState = SWITCH_USING_NO; /*设置道岔未征用*/
}
else
{
/*非本保护区段征用,不处理*/
}
}
else if (SWITCH_USING_YES == cSwUsingState)
{
if ((0U == SwitchDataStru[wSwitchIndex].UsingBelongOverlapId) || (wOverlapId == SwitchDataStru[wSwitchIndex].UsingBelongOverlapId))
{
SwitchDataStru[wSwitchIndex].UsingBelongOverlapId = wOverlapId;
SwitchDataStru[wSwitchIndex].cSwitchUsingState = SWITCH_USING_YES; /*设置道岔征用*/
}
else
{
/*其它保护区段征用,不处理*/
}
}
else if (SWITCH_USING_APPLY == cSwUsingState)
{
if (0U == SwitchDataStru[wSwitchIndex].UsingBelongOverlapId)
{
SwitchDataStru[wSwitchIndex].UsingBelongOverlapId = wOverlapId;
SwitchDataStru[wSwitchIndex].cSwitchUsingState = SWITCH_USING_APPLY; /*设置道岔申请征用*/
}
else
{
/*已被征用/申请征用,不处理*/
}
}
else
{
if (wOverlapId == SwitchDataStru[wSwitchIndex].UsingBelongOverlapId)
{
SwitchDataStru[wSwitchIndex].UsingBelongOverlapId = wOverlapId;
SwitchDataStru[wSwitchIndex].cSwitchUsingState = SWITCH_USING_CANCEL; /*设置道岔申请取消征用*/
}
else
{
/*非本保护区段征用,不处理*/
}
}
}
else
{
/*入参检查失败,不处理*/
}
}
/*
* 功能描述: 设置道岔采集容忍起始周期
* 参数说明: const UINT16 switchId, 道岔ID
* const UINT32 cycNum 周期号
* 返回值
*/
void SetSwitchCollTolerateCycNum(const UINT16 switchId, const UINT32 cycNum)
{
UINT16 bufIndex = 0u; /*数组下标*/
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (bufIndex < SWITCH_SUM_MAX)
{
SwitchDataStru[bufIndex].SwitchCollTolerateCycNum = cycNum;
}
}
/*
* 功能描述: 获取道岔采集容忍起始周期
* 参数说明: const UINT16 switchId, 道岔ID
* 返回值 : UINT32 采集容忍起始周期
*/
UINT32 GetSwitchCollTolerateCycNum(const UINT16 switchId)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT32 retVal = CI_ERROR;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (bufIndex < SWITCH_SUM_MAX)
{
retVal = SwitchDataStru[bufIndex].SwitchCollTolerateCycNum;
}
return retVal;
}
/*
* 功能描述: 设置道岔采集位置
* 参数说明: const UINT16 switchId, 道岔ID
* const UINT8 chSwitchColpos 位置
* 返回值
*
*/
void SetSwitchCollPos(const UINT16 switchId, const UINT8 chSwitchColpos)
{
UINT16 bufIndex = 0u; /*数组下标*/
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (bufIndex < SWITCH_SUM_MAX)
{
SwitchDataStru[bufIndex].SwitchColPosition = chSwitchColpos;
}
}
/*
* 功能描述: 获取道岔采集位置
* 参数说明: const UINT16 switchId, 道岔ID
* 返回值 : 采集道岔采集位置 1定位 2反位 4四开 8移动
*/
UINT8 GetSwitchCollPos(const UINT16 switchId)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT8 retVal = CI_ERROR;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (bufIndex < SWITCH_SUM_MAX)
{
retVal = SwitchDataStru[bufIndex].SwitchColPosition;
}
return retVal;
}
/*
* 功能描述:设置互联互通CI指定ID道岔的防护锁闭状态
* 参数说明:const UINT16 switchId 道岔ID
* const UINT8 lockStatus 锁闭状态
* 返 回 值:无
* Created By LQ 2025.05.27
*/
void SetHlhtCiSwitchPlockStatus(const UINT16 switchId, const UINT8 lockStatus)
{
UINT16 bufIndex = 0U; /*数组下标*/
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (SWITCH_SUM_MAX > bufIndex)
{
if ((SWITCH_LOCK_STATUS_PROTECT == lockStatus) || (SWITCH_LOCK_STATUS_NO == lockStatus) || (SWITCH_LOCK_STATUS_DAP == lockStatus))
{
SwitchDataStru[bufIndex].LockStatus = lockStatus;
}
else
{
/*状态非法,不处理*/
}
}
else
{
/*保护区段ID非法,不做处理*/
}
}
/*
* 功能描述:设置OC道岔转辙机状态
* 参数说明:const UINT16 switchId 道岔ID
const UINT8 chSwitchIncldeZzjNum 转辙机数量
UINT8* szSwitchIncldeZzjState 转辙机状态
* 返 回 值:无
*/
void SetOcSwitchZzjState(const UINT16 switchId,const UINT8 chSwitchIncldeZzjNum,UINT8* szSwitchIncldeZzjState)
{
UINT16 bufIndex = 0U; /*数组下标*/
UINT8 ii = 0U;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (NULL == szSwitchIncldeZzjState)
{
; /*指针为空,不做处理*/
}
else
{
if (SWITCH_SUM_MAX > bufIndex)
{
SwitchDataStru[bufIndex].chSwitchIncldeZzjNum = chSwitchIncldeZzjNum; /*设置道岔包含转辙机数目*/
/*设置道岔包含转辙机的继电器状态*/
for (ii = 0; ii < chSwitchIncldeZzjNum; ii++)
{
SwitchDataStru[bufIndex].szSwitchIncldeZzjState[ii] = szSwitchIncldeZzjState[ii];
}
}
else
{
/*保护区段ID非法,不做处理*/
}
}
}
/*
* 功能描述:获取道岔转辙机状态
* 参数说明:const UINT16 switchId 道岔ID
* 返 回 值:UINT8* 转辙机状态
*/
UINT8* GetSwitchZzjState(const UINT16 switchId)
{
UINT16 bufIndex = 0U; /*数组下标*/
UINT8 ii = 0U;
UINT8 *retVal = NULL; /*返回值*/
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (SWITCH_SUM_MAX > bufIndex)
{
retVal = SwitchDataStru[bufIndex].szSwitchIncldeZzjState;
}
return retVal;
}
/*
* 功能描述:设置OC道岔转辙机继电器吸起、落下
* 参数说明:const UINT16 switchId 道岔ID
const UINT16 zzjIndex 转辙机索引
const UINT8 zzjState 继电器状态
* 返 回 值:无
*/
void SetSwitchZzjState(const UINT16 switchId, const UINT8 zzjIndex, const UINT8 zzjState)
{
UINT16 relaydingwei1 = 0U; /*继电器定位1ID*/
UINT16 relaydingwei2 = 0U; /*继电器定位2ID*/
UINT16 relayfanwei1 = 0U; /*继电器反位1ID*/
UINT16 relayfanwei2 = 0U; /*继电器反位2ID*/
ZzjPowerConfigDataStruct* zzjPowerConfigData = NULL; /*道岔转辙机继电器配置数据结构指针*/
zzjPowerConfigData = GetSwitchZzjPowerConfigData(switchId); /*获取转辙机继电器配置数据结构指针*/
relaydingwei1 = zzjPowerConfigData[zzjIndex].ZzjDingweiPower1;
relaydingwei2 = zzjPowerConfigData[zzjIndex].ZzjDingweiPower2;
relayfanwei1 = zzjPowerConfigData[zzjIndex].ZzjFanweiPower1;
relayfanwei2 = zzjPowerConfigData[zzjIndex].ZzjFanweiPower2;
/* 继电器ID参数检查 */
if((RELAY_SUM_MAX > relaydingwei1)&&(RELAY_SUM_MAX > relaydingwei2)
&&(RELAY_SUM_MAX > relayfanwei1)&&(RELAY_SUM_MAX > relayfanwei2))
{
switch (zzjState)
{
case OC_SWITCH_POSITION_DINGWEI:
/*转辙机驱动定位,定位继电器吸起,反位继电器落下,亮绿灯*/
SetRelayDriveState(relaydingwei1, RELAY_DRIVE_STATE_UP);
SetRelayDriveState(relaydingwei2, RELAY_DRIVE_STATE_UP);
SetRelayDriveState(relayfanwei1, RELAY_DRIVE_STATE_DOWN);
SetRelayDriveState(relayfanwei2, RELAY_DRIVE_STATE_DOWN);
break;
case OC_SWITCH_POSITION_FANWEI:
/*转辙机驱动反位,反位位继电器吸起,反位继电器落下,亮黄灯*/
SetRelayDriveState(relaydingwei1, RELAY_DRIVE_STATE_DOWN);
SetRelayDriveState(relaydingwei2, RELAY_DRIVE_STATE_DOWN);
SetRelayDriveState(relayfanwei1, RELAY_DRIVE_STATE_UP);
SetRelayDriveState(relayfanwei2, RELAY_DRIVE_STATE_UP);
break;
default:
/*转辙机非定位、反位,定位、反位继电器均落下,灭灯*/
SetRelayDriveState(relaydingwei1, RELAY_DRIVE_STATE_DOWN);
SetRelayDriveState(relaydingwei2, RELAY_DRIVE_STATE_DOWN);
SetRelayDriveState(relayfanwei1, RELAY_DRIVE_STATE_DOWN);
SetRelayDriveState(relayfanwei2, RELAY_DRIVE_STATE_DOWN);
break;
}
}
else
{
/*参数检查失败,不处理*/
}
}
/*
* 功能描述:设置OC道岔转辙机标识灯状态
* 参数说明:UINT16 switchId 道岔ID
* 返 回 值:无
*/
void SetOcSwitchIndicatorLightStatus(UINT16 switchId)
{
UINT8 szSwitchZzjStateNum = 0U; /*道岔包含转辙机数目*/
UINT8 ii = 0U;
UINT8 *switchzzjState = NULL; /*道岔包含转辙机状态指针*/
switchzzjState = GetSwitchZzjState(switchId); /*获取道岔包含转辙机状态指针*/
if(NULL == switchzzjState)
{
/*获取道岔包含转辙机状态指针失败,不处理*/
}
else
{
szSwitchZzjStateNum = SwitchDataStru[switchId].chSwitchIncldeZzjNum;
/*设置道岔包含转辙机的继电器状态*/
for (ii = 0; ii < szSwitchZzjStateNum; ii++)
{
SetSwitchZzjState(switchId, ii, switchzzjState[ii]);
}
}
}
/*
* 功能描述: 获取道岔防护锁闭信息
* 参数说明: const UINT16 switchId, 道岔ID
* 返回值 : 道岔防护锁闭进路ID
*/
const UINT16* GetSwitchPLockedRouteIdArr(const UINT16 switchId)
{
UINT16 bufIndex = 0U; /*数组下标*/
UINT16* retVal = CI_ERROR;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (SWITCH_SUM_MAX >bufIndex )
{
retVal = SwitchDataStru[bufIndex].PLockedRouteIdArr;
}
return retVal;
}
/*
* 功能描述: 获取道岔防护锁闭进路数
* 参数说明: const UINT16 switchId, 道岔ID
* 返回值 防护锁闭进路数
*/
UINT8 GetSwitchPLockedRouteNum(const UINT16 switchId)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT8 retVal = CI_ERROR;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (bufIndex < SWITCH_SUM_MAX)
{
retVal = SwitchDataStru[bufIndex].PLockedRouteNum;
}
return retVal;
}
/*
* 功能描述: 获取道岔是否被指定进路防护锁闭
* 参数说明: const UINT16 switchId, 道岔ID
* 返回值 : CI_SUCCESS 已经被锁闭或入参不合法,CI_ERROR 未被该进路防护锁闭
*/
UINT8 GetSwitchThisRoutePLocked(const UINT16 switchId, const UINT16 routeId)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT8 retVal = CI_ERROR;
UINT8 i = 0u;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if ((SWITCH_SUM_MAX >bufIndex)&&(0u < routeId))
{
for (i = 0u; i < SwitchDataStru[bufIndex].PLockedRouteNum; i++)
{
if (routeId == SwitchDataStru[bufIndex].PLockedRouteIdArr[i])
{
retVal = CI_SUCCESS;
break;
}
}
}
else
{
retVal = CI_SUCCESS;/*入参不合法*/
}
return retVal;
}
/*
* 功能描述: 获取道岔是否被指定保护区段防护锁闭
* 参数说明: const UINT16 switchId, 道岔ID
* 返回值 : CI_SUCCESS 已经被锁闭或入参不合法,CI_ERROR 未被该保护区段防护锁闭
*/
UINT8 GetSwitchThisOverlapPLocked(const UINT16 switchId, const UINT16 overlapId)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT8 retVal = CI_ERROR;
UINT8 i = 0u;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if ((SWITCH_SUM_MAX > bufIndex) && (0u < overlapId))
{
for (i = 0u; i < SwitchDataStru[bufIndex].PLockedOverlapNum; i++)
{
if (overlapId == SwitchDataStru[bufIndex].PLockedOverlapIdArr[i])
{
retVal = CI_SUCCESS;
break;
}
}
}
else
{
retVal = CI_SUCCESS;/*入参不合法*/
}
return retVal;
}
/*
* 功能描述: 设置道岔指定OC的控制模式
* 参数说明: const UINT16 switchId, 道岔ID
* const UINT8 ocId 指定OC
* const UINT8 controlMode 控制模式
* 返回值 void
* add by mpt 20260326
*/
void SetSwitchThisOcCotrolMode(const UINT16 switchId, const UINT8 ocId,const UINT8 controlMode)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT8 i = 0u;
UINT8 chSwitchIncludeOcNum = 0U;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
chSwitchIncludeOcNum = GetSwitchIncludeOcNum(switchId);
if ((SWITCH_SUM_MAX > bufIndex) && (0u < ocId))
{
for (i = 0u; i < chSwitchIncludeOcNum; i++)
{
if (ocId == SwitchDataStru[bufIndex].belongOCData[i].OcId)
{
if ((MAIN_CONTROL == controlMode) || (STANDBY_CONTROL == controlMode) || (NO_CONTROL_FUN == controlMode) || (ERR_MODE_CONTROL == controlMode))
{
SwitchDataStru[bufIndex].belongOCData[i].controlMode = controlMode;
}
break;
}
}
}
else
{
/*什么也不做*/
}
}
/*
* 功能描述: 获取道岔指定OC的控制模式
* 参数说明: const UINT16 switchId, 道岔ID
* const UINT8 ocId 指定OC
* 返回值 控制模式
* add by mpt 20260326
*/
UINT8 GetSwitchThisOcCotrolMode(const UINT16 switchId, const UINT8 ocId)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT8 retVal = CI_ERROR;
UINT8 i = 0u;
UINT8 chSwitchIncludeOcNum = 0U;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
chSwitchIncludeOcNum = GetSwitchIncludeOcNum(switchId);
if ((SWITCH_SUM_MAX > bufIndex) && (0u < ocId))
{
for (i = 0u; i < chSwitchIncludeOcNum; i++)
{
if (ocId == SwitchDataStru[bufIndex].belongOCData[i].OcId)
{
retVal= SwitchDataStru[bufIndex].belongOCData[i].controlMode;
break;
}
}
}
else
{
/*什么也不做*/
}
return retVal;
}
/*
* 功能描述: 设置道岔的主控OCID
* 参数说明: const UINT16 switchId, 道岔ID
* const UINT8 ocId 指定OC
* 返回值 void
* add by mpt 20260326
*/
void SetSwitchMainCotrolOCId(const UINT16 switchId, const UINT8 ocId)
{
UINT16 bufIndex = 0u; /*数组下标*/
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (SWITCH_SUM_MAX > bufIndex)
{
SwitchDataStru[bufIndex].mainControlOcId = ocId;
}
else
{
/*什么也不做*/
}
}
/*
* 功能描述: 获取道岔的主控OC
* 参数说明: const UINT16 switchId 道岔ID
* 返回值 主控OCId
* add by mpt 20260326
*/
UINT8 GetSwitchMainCotrolOCId(const UINT16 switchId)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT8 retVal = CI_ERROR;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (SWITCH_SUM_MAX > bufIndex)
{
retVal = SwitchDataStru[bufIndex].mainControlOcId;
}
else
{
/*什么也不做*/
}
return retVal;
}
/*
* 功能描述: 设置道岔指定OC执行电插箱的状态
* 参数说明: const UINT16 switchId, 道岔ID
* const UINT8 ocId 指定OC
* const UINT8 state 状态
* 返回值 void
* add by mpt 20260326
*/
void SetSwitchOcPlusBoxSateState(const UINT16 switchId, const UINT8 ocId, const UINT8 state)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT8 i = 0u;
UINT8 chOCIndex = 0U;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
chOCIndex = GetSwitchThisOCIndex(switchId, ocId);
if ((SWITCH_SUM_MAX > bufIndex) && (SWITCH_BELONG_OC_MAX >chOCIndex))
{
SwitchDataStru[bufIndex].belongOCData[chOCIndex].PlusBoxSate = state;
}
else
{
/*什么也不做*/
}
}
/*
* 功能描述: 获取道岔在指定OC中的执行电插箱状态
* 参数说明: const UINT16 switchId, 道岔ID
* const UINT8 ocId 指定OC
* const UINT8 state 状态
* 返回值 : 0x55 转辙机执行电表示电均表示正常
* 0xAA 转辙机存在执行电熔丝或表示电熔丝报警
* 0 非法状态
* add by mpt 20260326
*/
UINT8 GetSwitchOcPlusBoxSateState(const UINT16 switchId, const UINT8 ocId)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT8 ret = 0u;
UINT8 chOCIndex = 0U;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
chOCIndex = GetSwitchThisOCIndex(switchId, ocId);
if ((SWITCH_SUM_MAX > bufIndex) && (SWITCH_BELONG_OC_MAX > chOCIndex))
{
ret = SwitchDataStru[bufIndex].belongOCData[chOCIndex].PlusBoxSate;
}
else
{
/*什么也不做*/
}
return ret;
}
/*
* 功能描述: 设置指定道岔在该OC的转辙机板卡ID的状态
* 参数说明: const UINT16 switchId 道岔ID
* const UINT8 ocId OCID
* const UINT8 boardId 板卡ID
* UINT8 state 板卡故障状态
* 返回值 void
* add by mpt 20260326
*/
void SetSwitchThisOCBoardState(const UINT16 switchId, const UINT8 ocId, const UINT8 boardId, const UINT8 state)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT8 chBoardIndex = 0u;
UINT8 chOCIndex = 0u;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (SWITCH_SUM_MAX > bufIndex)
{
chOCIndex = GetSwitchThisOCIndex(switchId, ocId);
chBoardIndex = GetSwitchThisOCBoardIDindex(switchId, ocId, boardId);
if ((MAX_OC_SWITCH_INCLUDE_BOARD_NUM > chBoardIndex)&&(SWITCH_BELONG_OC_MAX >chOCIndex))
{
SwitchDataStru[bufIndex].belongOCData[chOCIndex].BoardStateBuf[chBoardIndex] = state;
}
else
{
/*nothing*/
}
}
else
{
/*nothing*/
}
}
/*
* 功能描述: 获取指定道岔在该OC中是否存在某组转辙机板故障
* 参数说明: const UINT16 switchId 道岔ID
* const UINT8 ocId OCID
* const UINT8 boardId 板卡ID
* UINT8 state 板卡故障状态
* 返回值 SWITCH_BOARD_FAULT 故障
* SWITCH_BOARD_NORMAL 正常
* add by mpt 20260326
*/
UINT8 GetSwitchThisOCBoardState(const UINT16 switchId, const UINT8 ocId)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT8 num = 0u;
UINT8 i = 0u;
UINT8 chSwitchThisOCBoardNum = 0u;
UINT8 chOCIndex = 0u;
UINT8 addrAState = 0u;
UINT8 addrBState = 0u;
UINT8 retVal = SWITCH_BOARD_FAULT;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (SWITCH_SUM_MAX > bufIndex)
{
chOCIndex = GetSwitchThisOCIndex(switchId, ocId);
chSwitchThisOCBoardNum = GetSwitchThisOCBoardNum(switchId, ocId);
if (SWITCH_BELONG_OC_MAX > chOCIndex)
{
if (0u < chSwitchThisOCBoardNum)
{
retVal = SWITCH_BOARD_NORMAL;/*先置为正常*/
for (i = 0u; i < (chSwitchThisOCBoardNum - 1u); i += 2u)
{
addrAState = SwitchDataStru[bufIndex].belongOCData[chOCIndex].BoardStateBuf[i];
addrBState = SwitchDataStru[bufIndex].belongOCData[chOCIndex].BoardStateBuf[i + 1u];
if ((SWITCH_BOARD_FAULT == addrAState) && (SWITCH_BOARD_FAULT == addrBState))
{
retVal = SWITCH_BOARD_FAULT;
break;
}
}
}
else
{/*异常分支,置为故障*/
retVal = SWITCH_BOARD_FAULT;
}
}
}
else
{
/*nothing*/
}
return retVal;
}
/*
* 功能描述: 设置道岔指定OC的主控命令
* 参数说明: const UINT16 switchId, 道岔ID
* const UINT8 ocId 指定OC
* const UINT8 state 状态
* 返回值 void
* add by mpt 20260326
*/
void SetSwitchThisOcOutControlCmd(const UINT16 switchId, const UINT8 ocId, const UINT8 state)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT8 chOCIndex = 0U;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
chOCIndex = GetSwitchThisOCIndex(switchId, ocId);
if ((SWITCH_SUM_MAX > bufIndex) && (SWITCH_BELONG_OC_MAX >chOCIndex))
{
if ((MAIN_CONTROL == state) || (STANDBY_CONTROL == state)||(NO_CONTROL_FUN == state))
{
SwitchDataStru[bufIndex].belongOCData[chOCIndex].OutControlCmd = state;
}
}
else
{
/*什么也不做*/
}
}
/*
* 功能描述: 获取道岔指定OC的主控命令
* 参数说明: const UINT16 switchId, 道岔ID
* const UINT8 ocId 指定OC
* const UINT8 state 状态
* 返回值 0x55 主控
* 0xaa 备控
* add by mpt 20260326
*/
UINT8 GetSwitchThisOcOutControlCmd(const UINT16 switchId, const UINT8 ocId)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT8 chOCIndex = 0U;
UINT8 retVal = 0U;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
chOCIndex = GetSwitchThisOCIndex(switchId, ocId);
if ((SWITCH_SUM_MAX > bufIndex) && (SWITCH_BELONG_OC_MAX > chOCIndex))
{
retVal = SwitchDataStru[bufIndex].belongOCData[chOCIndex].OutControlCmd;
}
else
{
/*什么也不做*/
}
return retVal;
}
/*
* 功能描述: 设置道岔指定OC的主控命令的设置周期
* 参数说明: const UINT16 switchId, 道岔ID
* const UINT8 ocId 指定OC
* const UINT32 cycnum 周期
* 返回值 void
* add by mpt 20260326
*/
void SetSwitchOutMainContrCmdCycNum(const UINT16 switchId, const UINT8 ocId,const UINT32 cycnum)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT8 chOCIndex = 0U;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
chOCIndex = GetSwitchThisOCIndex(switchId, ocId);
if ((SWITCH_SUM_MAX > bufIndex) && (SWITCH_BELONG_OC_MAX > chOCIndex))
{
SwitchDataStru[bufIndex].belongOCData[chOCIndex].OutMainControlCmdCycNum = cycnum;
}
else
{
/*什么也不做*/
}
}
/*
* 功能描述:获取道岔指定OC的主控命令的设置周期
* 参数说明: const UINT16 switchId, 道岔ID
* const UINT8 ocId 指定OC
* 返回值 void
* add by mpt 20260326
*/
UINT32 GetSwitchOutMainContrCmdCycNum(const UINT16 switchId, const UINT8 ocId)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT8 chOCIndex = 0U;
UINT32 retVal = 0u;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
chOCIndex = GetSwitchThisOCIndex(switchId, ocId);
if ((SWITCH_SUM_MAX > bufIndex) && (SWITCH_BELONG_OC_MAX > chOCIndex))
{
retVal = SwitchDataStru[bufIndex].belongOCData[chOCIndex].OutMainControlCmdCycNum;
}
else
{
/*什么也不做*/
}
return retVal;
}
/*
* 功能描述: 设置道岔驱动命令下发起始周期
* 参数说明: const UINT16 switchId, 道岔ID
* const UINT32 cycNum 周期号
* 返回值
* add mpt by 20260327
*/
void SetSwitchOutputDrvCmdCycNum(const UINT16 switchId, const UINT32 cycNum)
{
UINT16 bufIndex = 0u; /*数组下标*/
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (SWITCH_SUM_MAX >bufIndex)
{
SwitchDataStru[bufIndex].SwitchOutputDrvCmdCycNum = cycNum;
}
}
/*
* 功能描述: 获取道岔驱动命令下发起始周期
* 参数说明: const UINT16 switchId, 道岔ID
* 返回值 : 道岔操作命令起始周期
* add mpt by 20260327
*/
UINT32 GetSwitchOutputDrvCmdCycNum(const UINT16 switchId)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT32 retVal = CI_ERROR;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (SWITCH_SUM_MAX > bufIndex)
{
retVal = SwitchDataStru[bufIndex].SwitchOutputDrvCmdCycNum;
}
return retVal;
}
/*
* 功能描述: 设置道岔寻找表示位置
* 参数说明: const UINT16 switchId, 道岔ID
* const UINT8 ocId OCID
* const UINT8 chFindCmd 寻表命令
* 返回值
* add mpt by 20260327
*/
void SetSwitchThisOcFindPostionCmd(const UINT16 switchId, const UINT8 ocId, const UINT8 chFindCmd)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT8 chOCIndex = 0U;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (SWITCH_SUM_MAX > bufIndex)
{
chOCIndex = GetSwitchThisOCIndex(switchId, ocId);
if (SWITCH_BELONG_OC_MAX > chOCIndex)
{
if ((FIND_DINGWEI_CMD == chFindCmd)||(FIND_FANWEI_CMD == chFindCmd) || (INIT_FIND_CMD == chFindCmd)||(NO_FIND_CMD == chFindCmd))
{
SwitchDataStru[bufIndex].belongOCData[chOCIndex].FindPostionCmd = chFindCmd;
}
else
{
/*无处理*/
}
}
}
}
/*
* 功能描述: 获取道岔寻找表示命令
* 参数说明: const UINT16 switchId, 道岔ID
* const UINT8 ocId OCID
* 返回值 道岔寻找表示位置
* add mpt by 20260327
*/
UINT8 GetSwitchThisOcFindPostionCmd(const UINT16 switchId, const UINT8 ocId)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT8 chOCIndex = 0U;
UINT8 retVal = 0u;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (SWITCH_SUM_MAX > bufIndex)
{
chOCIndex = GetSwitchThisOCIndex(switchId, ocId);
if (SWITCH_BELONG_OC_MAX > chOCIndex)
{
retVal = SwitchDataStru[bufIndex].belongOCData[chOCIndex].FindPostionCmd;
}
}
return retVal;
}
/*
* 功能描述: 获取道岔寻找表示命令起始周期
* 参数说明: const UINT16 switchId, 道岔ID
* const UINT8 ocId OCID
* 返回值 :道岔寻找表示命令起始周期
* add mpt by 20260327
*/
UINT32 GetSwitchThisOcFindCmdCycNum(const UINT16 switchId, const UINT8 ocId)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT8 chOCIndex = 0U;
UINT32 retVal = 0u;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (SWITCH_SUM_MAX > bufIndex)
{
chOCIndex = GetSwitchThisOCIndex(switchId, ocId);
if (SWITCH_BELONG_OC_MAX > chOCIndex)
{
retVal = SwitchDataStru[bufIndex].belongOCData[chOCIndex].FindCmdStartCycNum;
}
}
return retVal;
}
/*
* 功能描述: 设置道岔寻找表示命令起始周期
* 参数说明: const UINT16 switchId, 道岔ID
* const UINT8 ocId OCID
* UINT32 cycNum 周期号
* 返回值 void
* add mpt by 20260402
*/
void SetSwitchThisOcFindCmdCycNum(const UINT16 switchId, const UINT8 ocId, const UINT32 cycNum)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT8 chOCIndex = 0U;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (SWITCH_SUM_MAX > bufIndex)
{
chOCIndex = GetSwitchThisOCIndex(switchId, ocId);
if (SWITCH_BELONG_OC_MAX > chOCIndex)
{
SwitchDataStru[bufIndex].belongOCData[chOCIndex].FindCmdStartCycNum = cycNum;
}
}
}
/*
* 功能描述: 设置判断混线起始周期号
* 参数说明: const UINT16 switchId, 道岔ID
* const UINT8 ocIndex OC下标
* UINT32 cycNum 周期号
* 返回值 void
* add by wyd 20260604
*/
void SetSwitchRedunJudgHunXianStCyc(const UINT16 switchId, const UINT8 chOCIndex, const UINT32 cycNum)
{
UINT16 bufIndex = 0u; /*数组下标*/
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if ((SWITCH_SUM_MAX > bufIndex) && (SWITCH_REDUN_COLL_MAX > chOCIndex))
{
SwitchDataStru[bufIndex].RedunCollData[chOCIndex].dwRedunJudgHunXianStCyc = cycNum;
}
else
{
/*nothing*/
}
}
/*
* 功能描述:获取判断混线起始周期号
* 参数说明:const UINT16 switchId, 道岔ID
* const UINT8 ocIndex OC下标
* 返回值 :周期号
* add by wyd 20260604
*/
UINT32 GetSwitchRedunJudgHunXianStCyc(const UINT16 switchId, const UINT8 chOCIndex)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT32 cycNum = 0u;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if ((SWITCH_SUM_MAX > bufIndex) && (SWITCH_REDUN_COLL_MAX > chOCIndex))
{
cycNum = SwitchDataStru[bufIndex].RedunCollData[chOCIndex].dwRedunJudgHunXianStCyc;
}
else
{
/*nothing*/
}
return cycNum;
}
/*
* 功能描述: 设置实际混线起始周期号
* 参数说明: const UINT16 switchId, 道岔ID
* const UINT8 ocIndex OC下标
* UINT32 cycNum 周期号
* 返回值 void
* add by wyd 20260604
*/
void SetSwitchRedunRealHunXianStCyc(const UINT16 switchId, const UINT8 chOCIndex, const UINT32 cycNum)
{
UINT16 bufIndex = 0u; /*数组下标*/
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if ((SWITCH_SUM_MAX > bufIndex) && (SWITCH_REDUN_COLL_MAX > chOCIndex))
{
SwitchDataStru[bufIndex].RedunCollData[chOCIndex].dwRedunRealHunXianStCyc = cycNum;
}
else
{
/*nothing*/
}
}
/*
* 功能描述:获取实际混线起始周期号
* 参数说明:const UINT16 switchId, 道岔ID
* const UINT8 ocIndex OC下标
* 返回值 :周期号
* add by wyd 20260604
*/
UINT32 GetSwitchRedunRealHunXianStCyc(const UINT16 switchId, const UINT8 chOCIndex)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT32 cycNum = 0u;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if ((SWITCH_SUM_MAX > bufIndex) && (SWITCH_REDUN_COLL_MAX > chOCIndex))
{
cycNum = SwitchDataStru[bufIndex].RedunCollData[chOCIndex].dwRedunRealHunXianStCyc;
}
else
{
/*nothing*/
}
return cycNum;
}
/*
* 功能描述: 设置混线恢复状态
* 参数说明: const UINT16 switchId, 道岔ID
* const UINT8 ocIndex OC下标
* const UINT8 cHunXianStt 混线恢复状态
* REDUN_HX_RECOV_1100、REDUN_HX_RECOV_1010、REDUN_HX_RECOV_0011:设置
* 0:清除
* 返回值 void
* add by wyd 20260604
*/
void SetSwitchRedunHunXianRecovStt(const UINT16 switchId, const UINT8 chOCIndex, const UINT8 cHunXianStt)
{
UINT16 bufIndex = 0u; /*数组下标*/
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if ((SWITCH_SUM_MAX > bufIndex) && (SWITCH_REDUN_COLL_MAX > chOCIndex))
{
if ((REDUN_HX_RECOV_1100 == cHunXianStt) || (REDUN_HX_RECOV_1010 == cHunXianStt)
|| (REDUN_HX_RECOV_0011 == cHunXianStt) || (REDUN_HX_RECOV_ALL == cHunXianStt))
{
/*记录混线恢复采集*/
SwitchDataStru[bufIndex].RedunCollData[chOCIndex].cHunXianRecovStt |= cHunXianStt;
}
else
{
/*清空混线恢复采集*/
SwitchDataStru[bufIndex].RedunCollData[chOCIndex].cHunXianRecovStt = 0u;
}
}
else
{
/*nothing*/
}
}
/*
* 功能描述:获取混线恢复状态
* 参数说明:const UINT16 switchId, 道岔ID
* const UINT8 ocIndex OC下标
* 返回值 :混线恢复状态
* add by wyd 20260604
*/
UINT8 GetSwitchRedunHunXianRecovStt(const UINT16 switchId, const UINT8 chOCIndex)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT8 RtnValue = 0u;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if ((SWITCH_SUM_MAX > bufIndex) && (SWITCH_REDUN_COLL_MAX > chOCIndex))
{
RtnValue = SwitchDataStru[bufIndex].RedunCollData[chOCIndex].cHunXianRecovStt;
}
else
{
/*nothing*/
}
return RtnValue;
}
/*
* 功能描述: 设置采集故障起始周期号
* 参数说明: const UINT16 switchId, 道岔ID
* const UINT8 ocIndex OC下标
* UINT32 cycNum 周期号
* 返回值 void
* add by wyd 20260604
*/
void SetSwitchRedunFaultStCyc(const UINT16 switchId, const UINT8 chOCIndex, const UINT32 cycNum)
{
UINT16 bufIndex = 0u; /*数组下标*/
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if ((SWITCH_SUM_MAX > bufIndex) && (SWITCH_REDUN_COLL_MAX > chOCIndex))
{
SwitchDataStru[bufIndex].RedunCollData[chOCIndex].dwRedunFaultStCyc = cycNum;
}
else
{
/*nothing*/
}
}
/*
* 功能描述:获取采集故障起始周期号
* 参数说明:const UINT16 switchId, 道岔ID
* const UINT8 ocIndex OC下标
* 返回值 :周期号
* add by wyd 20260604
*/
UINT32 GetSwitchRedunFaultStCyc(const UINT16 switchId, const UINT8 chOCIndex)
{
UINT16 bufIndex = 0u; /*数组下标*/
UINT32 cycNum = 0u;
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if ((SWITCH_SUM_MAX > bufIndex) && (SWITCH_REDUN_COLL_MAX > chOCIndex))
{
cycNum = SwitchDataStru[bufIndex].RedunCollData[chOCIndex].dwRedunFaultStCyc;
}
else
{
/*nothing*/
}
return cycNum;
}
/*
* 功能描述: 设置冗余采集组合状态
* 参数说明: const UINT16 switchId, 道岔ID
* const UINT8 ocIndex OC下标
* UINT32 cycNum 周期号
* 返回值 void
* add by wyd 20260604
*/
void SetSwitchRedunCombineStt(const UINT16 switchId, const UINT8 chOCIndex, const UINT8 setValue)
{
UINT16 bufIndex = 0u; /*数组下标*/
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if ((SWITCH_SUM_MAX > bufIndex) && (SWITCH_REDUN_COLL_MAX > chOCIndex))
{
SwitchDataStru[bufIndex].RedunCollData[chOCIndex].cCombineStt = setValue;
}
else
{
/*nothing*/
}
}
/*
* 功能描述: 设置主控转辙机板采集道岔位置
* 参数说明: const UINT16 switchId, 道岔ID
* const UINT8 ocIndex OC下标
* UINT32 cycNum 周期号
* 返回值 void
* add by wyd 20260604
*/
void SetSwitchMainCollPos(const UINT16 switchId, const UINT8 setValue)
{
UINT16 bufIndex = 0u; /*数组下标*/
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if (SWITCH_SUM_MAX > bufIndex)
{
SwitchDataStru[bufIndex].cMainOcCollPos = setValue;
}
else
{
/*nothing*/
}
}
/*
* 功能描述: 设置冗余采集采集道岔位置
* 参数说明: const UINT16 switchId, 道岔ID
* const UINT8 ocIndex OC下标
* UINT32 cycNum 周期号
* 返回值 void
* add by wyd 20260604
*/
void SetSwitchRedunCollPos(const UINT16 switchId, const UINT8 chOCIndex, const UINT8 setValue)
{
UINT16 bufIndex = 0u; /*数组下标*/
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if ((SWITCH_SUM_MAX > bufIndex) && (SWITCH_REDUN_COLL_MAX > chOCIndex))
{
SwitchDataStru[bufIndex].RedunCollData[chOCIndex].cCollPos = setValue;
}
else
{
/*nothing*/
}
}
/*
* 功能描述: 设置冗余采集当周期混线状态
* 参数说明: const UINT16 switchId, 道岔ID
* const UINT8 ocIndex OC下标
* UINT32 cycNum 周期号
* 返回值 void
* add by wyd 20260604
*/
void SetSwitchRedunCurrHunXianStt(const UINT16 switchId, const UINT8 chOCIndex, const UINT8 setValue)
{
UINT16 bufIndex = 0u; /*数组下标*/
bufIndex = GetSwitchConfigBufIndex(switchId); /*获取道岔数组下标*/
if ((SWITCH_SUM_MAX > bufIndex) && (SWITCH_REDUN_COLL_MAX > chOCIndex))
{
SwitchDataStru[bufIndex].RedunCollData[chOCIndex].cCurrHunxianStt = setValue;
}
else
{
/*nothing*/
}
}